-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathstart.sh
executable file
·51 lines (41 loc) · 1.09 KB
/
start.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env bash
cd "${0%/*}"
[[ -f 'config.sh' ]] && source config.sh
if [[ "${DEV:-true}" == "true" ]] && [[ ! -z "$TAILWIND" ]]; then
npx tailwindcss -i ./static/style.css -o ./static/tailwind.css --watch=always 2>&1 \
| sed '/^[[:space:]]*$/d;s/^/[tailwind] /' &
PID=$!
fi
if [[ "${DEV:-true}" != "true" ]]; then
export ROUTES_CACHE=$(mktemp)
fi
# remove any old subscriptions; they are no longer valid
rm -rf pubsub
mkdir -p sessions
mkdir -p pubsub
mkdir -p data
mkdir -p uploads
PORT=${PORT:-3000}
TCP_PROVIDER=${TCP_PROVIDER:-tcpserver}
case "$TCP_PROVIDER" in
tcpserver)
echo -n "Listening on port "
tcpserver -1 -o -l 0 -H -R -c 1000 0 $PORT ./core.sh
;;
nc)
[[ ! -p nc_tunnel ]] && mkfifo nc_tunnel
[[ "${DEV:-true}" == true ]] && \
echo "WARNING: performance while using netcat will be significantly degraded!"
echo "Listening on port $PORT"
while true; do
< nc_tunnel nc -l $PORT | ./core.sh >nc_tunnel
done
;;
*)
echo "ERROR: unsupported TCP_PROVIDER"
exit 1
;;
esac
if [[ ! -z "$PID" ]]; then
kill "$PID"
fi