add admin scripts over from treehouse
would be nice to rewrite these as a standalone utility that integrates with Nix someday i guess
This commit is contained in:
parent
be6a47ae13
commit
384e64009e
12
admin/README.md
Normal file
12
admin/README.md
Normal file
|
@ -0,0 +1,12 @@
|
|||
# `admin`
|
||||
|
||||
Bunch of scripts I use to administrate the rkgk instance at <https://rkgk.app>.
|
||||
The full setup is:
|
||||
|
||||
- A systemd service runs `daemon.bash` in a separate user.
|
||||
- This script builds and runs the server.
|
||||
- It also listens for `reload` commands being sent through a FIFO, which can be used to make the server rebuild and rerun.
|
||||
- The `reload` command is sent by the `deploy.bash` script which runs on my own machine rather than the server.
|
||||
- This script causes a `git pull` and a `reload` command to be run.
|
||||
|
||||
This is more or less the same setup as <https://liquidex.house>.
|
28
admin/daemon.bash
Executable file
28
admin/daemon.bash
Executable file
|
@ -0,0 +1,28 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
source "${BASH_SOURCE%/*}/daemon/common.bash"
|
||||
|
||||
echo "PATH: $PATH"
|
||||
|
||||
trap 'trap - SIGTERM && kill 0' SIGTERM SIGINT EXIT
|
||||
|
||||
rm -f $reload_fifo
|
||||
mkfifo $reload_fifo
|
||||
|
||||
reload() {
|
||||
# This just kind of assumes recompilation doesn't take too long.
|
||||
kill "$rkgk_pid"
|
||||
cargo run --release -- serve --port 8083 > "$build_log" 2>&1 &
|
||||
rkgk_pid="$!"
|
||||
}
|
||||
|
||||
reload
|
||||
|
||||
while true; do
|
||||
read command < "$reload_fifo"
|
||||
case "$command" in
|
||||
reload)
|
||||
echo "Reloading"
|
||||
reload;;
|
||||
esac
|
||||
done
|
4
admin/daemon/common.bash
Normal file
4
admin/daemon/common.bash
Normal file
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
reload_fifo="/tmp/rkgk_reload.fifo"
|
||||
build_log="/tmp/rkgk_build.log"
|
11
admin/daemon/deploy.bash
Normal file
11
admin/daemon/deploy.bash
Normal file
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
cd ~/repo
|
||||
|
||||
source "${BASH_SOURCE%/*}/common.bash"
|
||||
|
||||
git pull
|
||||
bash "${BASH_SOURCE%/*}/reload.bash"
|
||||
|
||||
echo "^C to exit build log ($build_log)"
|
||||
tail --retry -f "$build_log"
|
6
admin/daemon/reload.bash
Normal file
6
admin/daemon/reload.bash
Normal file
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
source "${BASH_SOURCE%/*}/common.bash"
|
||||
|
||||
echo "Reloading"
|
||||
echo "reload" > "$reload_fifo"
|
3
admin/deploy.bash
Executable file
3
admin/deploy.bash
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
ssh "$RKGK_SERVER" -p "$RKGK_SERVER_PORT" "bash" "~/repo/admin/daemon/deploy.bash"
|
Loading…
Reference in a new issue