From 115adf2ed71b602204cd9fedb0e046e731aa7e38 Mon Sep 17 00:00:00 2001 From: Shulhan Date: Mon, 27 Nov 2023 00:48:59 +0700 Subject: _ops: add awwan scripts to manage awwan.org website Previously, this scripts is stored on my personal awwan workspace. As part of dog feeding, we expose how we manage awwan.org here, so people can see it as example of how awwan works. --- .gitignore | 1 + .ssh/config | 2 ++ Makefile | 7 +++++++ _ops/awwan.org/10_www-awwan.aww | 22 ++++++++++++++++++++++ _ops/awwan.org/awwan.env | 2 ++ .../etc/systemd/system/systemctl-restart@.service | 6 ++++++ _ops/awwan.org/etc/systemd/system/www-awwan.path | 9 +++++++++ .../awwan.org/etc/systemd/system/www-awwan.service | 12 ++++++++++++ 8 files changed, 61 insertions(+) create mode 100644 .ssh/config create mode 100644 _ops/awwan.org/10_www-awwan.aww create mode 100644 _ops/awwan.org/awwan.env create mode 100644 _ops/awwan.org/etc/systemd/system/systemctl-restart@.service create mode 100644 _ops/awwan.org/etc/systemd/system/www-awwan.path create mode 100644 _ops/awwan.org/etc/systemd/system/www-awwan.service diff --git a/.gitignore b/.gitignore index 13e93ea..62d8336 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.lck *.log +/.cache /CHANGELOG.html /README.html /_AUR/*.tar.zst diff --git a/.ssh/config b/.ssh/config new file mode 100644 index 0000000..59328e7 --- /dev/null +++ b/.ssh/config @@ -0,0 +1,2 @@ +Host awwan.org + Hostname awwan.org diff --git a/Makefile b/Makefile index 9601a15..e3c26f0 100644 --- a/Makefile +++ b/Makefile @@ -96,9 +96,16 @@ test-all: build-www: embed go build ./internal/cmd/www-awwan/ +.PHONY: serve-www serve-www: go run ./internal/cmd/www-awwan -dev +.PHONY: install-www +install-www: build-www + mkdir -p /data/app/bin/ + rsync --progress ./www-awwan /data/app/bin/ + +.PHONY: deploy-www deploy-www: GOOS=linux GOARCH=amd64 CGO_ENABLED=0 deploy-www: build-www rsync --progress ./www-awwan awwan.org:/data/app/bin/ diff --git a/_ops/awwan.org/10_www-awwan.aww b/_ops/awwan.org/10_www-awwan.aww new file mode 100644 index 0000000..fdfc7f3 --- /dev/null +++ b/_ops/awwan.org/10_www-awwan.aww @@ -0,0 +1,22 @@ +sudo mkdir -p /srv/awwan +sudo chown ms:ms -R /srv/awwan +sudo chmod +755 /srv/awwan + +#put!+0644 \ + {{.ScriptDir}}/etc/systemd/system/systemctl-restart@.service \ + /etc/systemd/system/systemctl-restart@.service + +sudo systemctl daemon-reload + +#put!+0644 \ + {{.ScriptDir}}/etc/systemd/system/www-awwan.path \ + /etc/systemd/system/www-awwan.path + +sudo systemctl enable --now www-awwan.path + +#put!+0644 \ + {{.ScriptDir}}/etc/systemd/system/www-awwan.service \ + /etc/systemd/system/www-awwan.service + +sudo systemctl enable --now www-awwan.service +sudo systemctl status www-awwan.service diff --git a/_ops/awwan.org/awwan.env b/_ops/awwan.org/awwan.env new file mode 100644 index 0000000..1d6efcb --- /dev/null +++ b/_ops/awwan.org/awwan.env @@ -0,0 +1,2 @@ +[awwan "www"] +bin = /data/app/bin/www-awwan diff --git a/_ops/awwan.org/etc/systemd/system/systemctl-restart@.service b/_ops/awwan.org/etc/systemd/system/systemctl-restart@.service new file mode 100644 index 0000000..800316e --- /dev/null +++ b/_ops/awwan.org/etc/systemd/system/systemctl-restart@.service @@ -0,0 +1,6 @@ +[Unit] +Description=systemctl-restart@%i + +[Service] +Type=oneshot +ExecStart=/bin/systemctl restart %i diff --git a/_ops/awwan.org/etc/systemd/system/www-awwan.path b/_ops/awwan.org/etc/systemd/system/www-awwan.path new file mode 100644 index 0000000..e6ac1c4 --- /dev/null +++ b/_ops/awwan.org/etc/systemd/system/www-awwan.path @@ -0,0 +1,9 @@ +[Unit] +Description="Watch www-awwan" + +[Path] +PathChanged={{.Val "awwan:www:bin"}} +Unit=systemctl-restart@%p.service + +[Install] +WantedBy=multi-user.target diff --git a/_ops/awwan.org/etc/systemd/system/www-awwan.service b/_ops/awwan.org/etc/systemd/system/www-awwan.service new file mode 100644 index 0000000..82f3de7 --- /dev/null +++ b/_ops/awwan.org/etc/systemd/system/www-awwan.service @@ -0,0 +1,12 @@ +[Unit] +Description=www-awwan +After=network-online.target + +[Service] +Type=simple +ExecStart={{.Val "awwan:www:bin"}} +Restart=on-failure +RestartSec=5 + +[Install] +WantedBy=default.target -- cgit v1.3