-
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathstart.sh
More file actions
executable file
·56 lines (45 loc) · 1.33 KB
/
Copy pathstart.sh
File metadata and controls
executable file
·56 lines (45 loc) · 1.33 KB
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
52
53
54
55
56
#!/usr/bin/env bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
export PROJECT_ROOT="${PROJECT_ROOT-$PWD}"
export CORE_SH="${CORE_SH-$SCRIPT_DIR/core.sh}"
export CONFIG_SH="${CONFIG_SH-$PROJECT_ROOT/config.sh}"
cd "$PROJECT_ROOT"
[[ -f "$CONFIG_SH" ]] && source "$CONFIG_SH"
if [[ "${DEV:-true}" == "true" ]] && [[ ! -z "$TAILWIND" ]]; then
npx tailwindcss@v3 -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