feat(admin): manage server updates and local configuration
ci / api / api (push) Successful in 52s
ci / contract / contract (сгенерированный код совпадает с openapi.yaml) (push) Successful in 1m9s
ci / mobile / mobile (Metro-бандл Android) (push) Successful in 1m35s
release / release (версия и заметки) (push) Successful in 5s
release / android (APK в релиз) (push) Successful in 4m6s
ci / db / db (push) Successful in 1m15s
ci / docker / docker (образы собираются — их сервер собирает сам при обновлении) (push) Successful in 1m19s
ci / ts / ts (packages + web) (push) Successful in 2m34s
release / desktop (Linux и Windows в релиз) (push) Successful in 14m27s
release / prune (старые файлы и прогоны) (push) Successful in 6s
ci / api / api (push) Successful in 52s
ci / contract / contract (сгенерированный код совпадает с openapi.yaml) (push) Successful in 1m9s
ci / mobile / mobile (Metro-бандл Android) (push) Successful in 1m35s
release / release (версия и заметки) (push) Successful in 5s
release / android (APK в релиз) (push) Successful in 4m6s
ci / db / db (push) Successful in 1m15s
ci / docker / docker (образы собираются — их сервер собирает сам при обновлении) (push) Successful in 1m19s
ci / ts / ts (packages + web) (push) Successful in 2m34s
release / desktop (Linux и Windows в релиз) (push) Successful in 14m27s
release / prune (старые файлы и прогоны) (push) Successful in 6s
This commit is contained in:
1 parent
e33abc948c
commit
a29a8b18ad
49 files changed
+3604
-353
No files matched your search
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env bash
|
||||
# Called explicitly by install.sh. Also usable once on existing installations.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")"
|
||||
DEPLOY="$(pwd -P)"
|
||||
DATA="${PIPU_DATA:-$(sed -n 's/^PIPU_DATA=//p' .env)}"
|
||||
DATA="${DATA:-/srv/pipu}"
|
||||
command -v python3 >/dev/null || { echo 'Install python3 (>=3.10) first' >&2; exit 1; }
|
||||
python3 -c 'import sys; assert sys.version_info >= (3, 10), "Python >=3.10 required"'
|
||||
[ -d /etc/systemd/system ] || { echo 'systemd is required for server management' >&2; exit 1; }
|
||||
mkdir -p "$DATA/management" /var/lib/pipu-management /usr/local/lib/pipu
|
||||
chown 65532:65532 "$DATA/management"
|
||||
chmod 700 "$DATA/management" /var/lib/pipu-management
|
||||
# Copy outside the checkout: switching revisions must not replace a running worker.
|
||||
install -m 700 server-agent.py /usr/local/lib/pipu/server-agent.py
|
||||
touch config.local
|
||||
chmod 600 config.local
|
||||
if [ -n "${SUDO_USER:-}" ]; then chown "$SUDO_USER" config.local; fi
|
||||
# systemd quoted arguments escape backslashes, quotes and specifiers.
|
||||
quote_unit() { printf '%s' "$1" | sed 's/\\/\\\\/g; s/"/\\"/g; s/%/%%/g'; }
|
||||
DEPLOY_UNIT="$(quote_unit "$DEPLOY")"
|
||||
MAILBOX_UNIT="$(quote_unit "$DATA/management")"
|
||||
cat > /etc/systemd/system/pipu-management.service <<EOF
|
||||
[Unit]
|
||||
Description=Pipu Music server management agent
|
||||
After=docker.service
|
||||
Requires=docker.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/bin/python3 /usr/local/lib/pipu/server-agent.py --deploy-dir "$DEPLOY_UNIT" --mailbox "$MAILBOX_UNIT" --state-dir /var/lib/pipu-management
|
||||
Restart=on-failure
|
||||
RestartSec=3
|
||||
UMask=0077
|
||||
KillMode=control-group
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
systemctl daemon-reload
|
||||
systemctl enable pipu-management.service
|
||||
systemctl restart pipu-management.service
|
||||
echo '→ управление сервером: pipu-management.service'
|
||||
Reference in new issue
Block a user