diff options
-rw-r--r-- | README.md | 24 | ||||
-rw-r--r-- | jigsaw-server.service | 14 | ||||
-rwxr-xr-x | upload.sh | 22 |
3 files changed, 33 insertions, 27 deletions
@@ -40,28 +40,10 @@ GRANT CREATE ON SCHEMA public TO jigsaw; \q ``` -run `cargo build --release` in the `server` directory -either on the server or on your computer, and copy `featuredpictures.txt potd.py getfeaturedpictures.py target/release/jigsaw-server` -to a directory owned by the jigsaw user, e.g. `/home/jigsaw/server`. install python3, and run `getfeaturedpictures.py` +copy over the `server` directory to your server and run `cargo build --release` there. install python3, and run `getfeaturedpictures.py` to get the list of featured pictures (this will take a while). -now you can run the `jigsaw-server` executable to start the backend, or create a systemd service to run it for you, e.g.: - -``` -[Unit] -Description=Jigsaw puzzle server -After=network.target - -[Service] -User=jigsaw -WorkingDirectory=/home/jigsaw/server -ExecStart=/home/jigsaw/server/jigsaw-server -Type=simple -Restart=always - -[Install] -WantedBy=default.target -RequiredBy=network.target -``` +now you can run the `target/release/jigsaw-server` executable to start the backend, or create a systemd service to run it for you, e.g. as in +the jigsaw-server.service file. now for the front-end, first change the `WEBSOCKET_URL_REMOTE` constant in `game.js` to a subdomain of your domain. run a proxy on your server to forward websocket traffic from that subdomain to port 54472 (this port can be configured in `server/src/main.rs`). diff --git a/jigsaw-server.service b/jigsaw-server.service new file mode 100644 index 0000000..6dcb046 --- /dev/null +++ b/jigsaw-server.service @@ -0,0 +1,14 @@ +[Unit] +Description=Jigsaw puzzle server +After=network.target + +[Service] +User=jigsaw +WorkingDirectory=/home/jigsaw/server +ExecStart=/home/jigsaw/server/target/release/jigsaw-server +Type=simple +Restart=always + +[Install] +WantedBy=default.target +RequiredBy=network.target @@ -14,14 +14,24 @@ done # if static-only argument is given, exit now printf '%s' "$@" | grep -q 'static-only' && exit 0 -cd server +echo 'Copying over server files…' +tar czf server.tar.gz $(git ls-files server) || exit 1 +scp server.tar.gz $REMOTE: || exit 1 +rm server.tar.gz +ssh $REMOTE <<EOF + +cd +tar xf server.tar.gz || exit 1 +rm server.tar.gz +echo 'Updating rust…' +rustup update stable +cd server/src echo 'Building server…' cargo build --release || exit 1 -echo 'Stopping server…' -ssh $REMOTE sudo systemctl stop jigsaw-server.service || exit 1 -echo 'Copying server files…' -scp -C featuredpictures.txt potd.py getfeaturedpictures.py target/release/jigsaw-server ${REMOTE}:server/ || exit 1 echo 'Restarting server…' -ssh $REMOTE sudo systemctl start jigsaw-server.service || exit 1 +sudo systemctl restart jigsaw-server.service || exit 1 + +EOF + cd .. echo 'Done!' |