-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.sh
executable file
·37 lines (29 loc) · 1.01 KB
/
main.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env bash
# Ensure protoc is installed
if ! command -v protoc &>/dev/null; then
echo "protoc not found, please download from https://github.com/protocolbuffers/protobuf/releases/" 1>&2
exit 1
fi
# Path to protobuf files
export proto="proto/goval.proto"
export proto_client="proto/client.proto"
# Ensure protobuf files exist
if [ ! -f "$proto" ] || [ ! -f "$proto_client" ]; then
echo "Missing protobuf files, please download them from https://govaldocs.pages.dev/api.proto and https://raw.githubusercontent.com/replit/protocol/master/client.proto" 1>&2
exit 1
fi
# Channels server PID file
channels_pid_file="runtime/channels.pid"
# Kill old channels server
if [ -f "$channels_pid_file" ]; then
kill "$(cat "$channels_pid_file")"
fi
# Start channels server
./src/utils/channels.sh 2>/dev/null &
channels_pid="$!"
echo -n "$channels_pid" >"$channels_pid_file"
# Start WebSocket server
websocketd-node --port 4096 --base64 ./src/bashval.sh
# Kill channels server
kill "$channels_pid"
rm "$channels_pid_file"