-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·32 lines (26 loc) · 1.07 KB
/
Copy pathdeploy.sh
File metadata and controls
executable file
·32 lines (26 loc) · 1.07 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
#!/bin/bash
set -euo pipefail
SERVER="root@webserver.skelpo.net"
REMOTE_DIR="/var/www/perryts.com"
SERVICE="perryts"
echo "==> Building site..."
npm run build:site
echo "==> Uploading server sources, helper, and static files..."
ssh "$SERVER" "mkdir -p $REMOTE_DIR/native-entry"
scp server.ts "$SERVER:$REMOTE_DIR/server.ts"
scp native-entry/server.ts "$SERVER:$REMOTE_DIR/native-entry/server.ts"
scp subscribe-server.mjs "$SERVER:$REMOTE_DIR/subscribe-server.mjs"
rsync -a --delete out/ "$SERVER:$REMOTE_DIR/out/"
echo "==> Compiling server on remote..."
ssh "$SERVER" "cd $REMOTE_DIR && perry compile native-entry/server.ts -o server && rm -f server.o _perry_stubs.*"
echo "==> Restarting services..."
ssh "$SERVER" "systemctl restart $SERVICE perryts-subscribe"
echo "==> Verifying..."
sleep 2
STATUS=$(curl -sL -o /dev/null -w "%{http_code}" https://perryts.com/)
if [ "$STATUS" = "200" ]; then
echo "==> Live at https://perryts.com/ (HTTP $STATUS)"
else
echo "==> WARNING: https://perryts.com/ returned HTTP $STATUS"
ssh "$SERVER" "systemctl status $SERVICE --no-pager -l"
fi