mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-09 19:56:48 +00:00
build: systemd runs the panel on hosts instead of supervisor
The installer and the manual installation install four systemd units (webvirt-cloud, webvirt-novncd, webvirt-socketiod, webvirt-worker) that run as the web server's user with absolute paths and read /etc/default/webvirtcloud. gunicorn, socketiod and the worker stop with KillMode=mixed, so they wind down their own children. supervisor, its installer code and the contributed systemd files go; the README gets the update, rollback and a one-time move from supervisor, and the installer refuses to run over a supervisor install. Docker keeps runit; novncd's runit script is the one-line form of the others.
This commit is contained in:
parent
fbef55fe2d
commit
837c5468ec
13 changed files with 129 additions and 343 deletions
|
|
@ -1,28 +1,4 @@
|
|||
#!/bin/sh
|
||||
|
||||
USER="www-data"
|
||||
DJANGO_PROJECT="/srv/webvirtcloud"
|
||||
PYTHON="$DJANGO_PROJECT/venv/bin/python3"
|
||||
NOVNCD="$DJANGO_PROJECT/console/novncd"
|
||||
LOG="/var/log/novncd.log"
|
||||
|
||||
cd "$DJANGO_PROJECT" || exit 1
|
||||
|
||||
# make novncd debug, verbose
|
||||
#PARAMS="-d -v"
|
||||
|
||||
if [ -x /sbin/setuser ]; then
|
||||
if [ -n "$PARAMS" ]; then
|
||||
# shellcheck disable=SC2086
|
||||
exec /sbin/setuser "$USER" "$PYTHON" "$NOVNCD" $PARAMS >> "$LOG" 2>&1
|
||||
else
|
||||
exec /sbin/setuser "$USER" "$PYTHON" "$NOVNCD" >> "$LOG" 2>&1
|
||||
fi
|
||||
elif command -v su >/dev/null 2>&1; then
|
||||
if [ -n "$PARAMS" ]; then
|
||||
# shellcheck disable=SC2086
|
||||
exec su -s /bin/sh "$USER" -c "exec \"$PYTHON\" \"$NOVNCD\" $PARAMS" >> "$LOG" 2>&1
|
||||
else
|
||||
exec su -s /bin/sh "$USER" -c "exec \"$PYTHON\" \"$NOVNCD\"" >> "$LOG" 2>&1
|
||||
fi
|
||||
fi
|
||||
cd /srv/webvirtcloud || exit 1
|
||||
exec /sbin/setuser www-data /srv/webvirtcloud/venv/bin/python3 /srv/webvirtcloud/console/novncd >> /var/log/novncd.log 2>&1
|
||||
|
|
|
|||
|
|
@ -1,37 +0,0 @@
|
|||
[program:webvirtcloud]
|
||||
command=/srv/webvirtcloud/venv/bin/gunicorn webvirtcloud.wsgi:application -c /srv/webvirtcloud/gunicorn.conf.py
|
||||
directory=/srv/webvirtcloud
|
||||
user=www-data
|
||||
autostart=true
|
||||
autorestart=true
|
||||
redirect_stderr=true
|
||||
|
||||
[program:novncd]
|
||||
command=/srv/webvirtcloud/venv/bin/python3 /srv/webvirtcloud/console/novncd
|
||||
directory=/srv/webvirtcloud
|
||||
user=www-data
|
||||
autostart=true
|
||||
autorestart=true
|
||||
redirect_stderr=true
|
||||
|
||||
# Serial console daemon; it refuses connections while SERIAL_CONSOLE_ENABLED
|
||||
# is off in settings.py.
|
||||
[program:socketiod]
|
||||
command=/srv/webvirtcloud/venv/bin/python3 /srv/webvirtcloud/console/socketiod
|
||||
directory=/srv/webvirtcloud
|
||||
user=www-data
|
||||
autostart=true
|
||||
autorestart=true
|
||||
redirect_stderr=true
|
||||
|
||||
# The job worker: one per installation. It drains running jobs for 60 s on
|
||||
# stop; supervisor waits a little longer before killing it.
|
||||
[program:webvirt-worker]
|
||||
command=/srv/webvirtcloud/venv/bin/python3 /srv/webvirtcloud/manage.py run_worker
|
||||
directory=/srv/webvirtcloud
|
||||
user=www-data
|
||||
environment=WEBVIRTCLOUD_LOG_FILE="/srv/webvirtcloud/data/webvirtcloud-worker.log"
|
||||
autostart=true
|
||||
autorestart=true
|
||||
stopwaitsecs=90
|
||||
redirect_stderr=true
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
# Ubuntu Service Files
|
||||
|
||||
I choose to install this service on Ubuntu 22.04
|
||||
|
||||
The process is not fully documented but I wanted to contribute the service files
|
||||
|
||||
The file webvirt is beeing installed into /etc/default/webvirt and allows you to easily change the location of the webvirtcloud installation path
|
||||
|
||||
The PATH variable being set for these services includes /usr/bin which contains the ssh executable. That is being used by webvirt-cloud and webvirt-novncd
|
||||
|
||||
Should the executable be located in another location please adjust the path
|
||||
|
||||
The error you should be seeing is "ssh executable not found"
|
||||
|
||||
|
||||
Use one of the two service managers: the installer sets up supervisor (`conf/supervisor/webvirtcloud.conf` runs the worker); these units are for manual installs without supervisor. Enabling both starts two workers; the second waits for the lease and does nothing.
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
#!/bin/bash
|
||||
FILEPATH=$(readlink -f "$0");
|
||||
SCRIPTPATH=$(dirname "$FILEPATH");
|
||||
cd "$SCRIPTPATH"
|
||||
cp webvirt-* /lib/systemd/system/
|
||||
cp webvirt /etc/default/
|
||||
echo Run to start services \"systemctl daemon-reload\; systemctl enable --now $(ls webvirt-* | tr "\n" " ")\"
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
WEBVIRT_PATH="/srv/webvirtcloud"
|
||||
PATH="$WEBVIRT_PATH/venv/bin:/usr/bin"
|
||||
|
|
@ -1,23 +1,19 @@
|
|||
[Unit]
|
||||
Description=Webvirt Cloud Webinterface
|
||||
Description=WebVirtCloud panel (gunicorn)
|
||||
Wants=network-online.target
|
||||
After=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
Restart=on-failure
|
||||
RestartSec=10
|
||||
User=www-data
|
||||
Group=www-data
|
||||
LimitNOFILE=64000
|
||||
AmbientCapabilities=CAP_NET_BIND_SERVICE
|
||||
EnvironmentFile=/etc/default/webvirt
|
||||
|
||||
ExecStart=/bin/bash -c "cd ${WEBVIRT_PATH};${WEBVIRT_PATH}/venv/bin/gunicorn webvirtcloud.wsgi:application -c ${WEBVIRT_PATH}/gunicorn.conf.py"
|
||||
|
||||
# Make sure stderr/stdout is captured in the systemd journal.
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
WorkingDirectory=/srv/webvirtcloud
|
||||
EnvironmentFile=-/etc/default/webvirtcloud
|
||||
ExecStart=/srv/webvirtcloud/venv/bin/gunicorn webvirtcloud.wsgi:application -c /srv/webvirtcloud/gunicorn.conf.py
|
||||
# gunicorn stops its workers itself; the rest of the group is killed after the timeout
|
||||
KillMode=mixed
|
||||
TimeoutStopSec=90
|
||||
Restart=on-failure
|
||||
RestartSec=10
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
|
|
|||
|
|
@ -1,23 +1,16 @@
|
|||
[Unit]
|
||||
Description=Webvirt Cloud NOVNCD
|
||||
Description=WebVirtCloud VNC console proxy (novncd)
|
||||
Wants=network-online.target
|
||||
After=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
Restart=on-failure
|
||||
RestartSec=10
|
||||
User=www-data
|
||||
Group=www-data
|
||||
LimitNOFILE=64000
|
||||
AmbientCapabilities=CAP_NET_BIND_SERVICE
|
||||
EnvironmentFile=/etc/default/webvirt
|
||||
|
||||
ExecStart=/bin/bash -c "cd ${WEBVIRT_PATH};${WEBVIRT_PATH}/venv/bin/python3 ${WEBVIRT_PATH}/console/novncd"
|
||||
|
||||
# Make sure stderr/stdout is captured in the systemd journal.
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
WorkingDirectory=/srv/webvirtcloud
|
||||
EnvironmentFile=-/etc/default/webvirtcloud
|
||||
ExecStart=/srv/webvirtcloud/venv/bin/python3 /srv/webvirtcloud/console/novncd
|
||||
Restart=on-failure
|
||||
RestartSec=10
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
|
|
|||
|
|
@ -1,23 +1,18 @@
|
|||
[Unit]
|
||||
Description=Webvirt Cloud serial console (socketiod; refuses connections unless SERIAL_CONSOLE_ENABLED = True)
|
||||
Description=WebVirtCloud serial console (socketiod; refuses connections unless SERIAL_CONSOLE_ENABLED)
|
||||
Wants=network-online.target
|
||||
After=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
Restart=on-failure
|
||||
RestartSec=10
|
||||
User=www-data
|
||||
Group=www-data
|
||||
LimitNOFILE=64000
|
||||
AmbientCapabilities=CAP_NET_BIND_SERVICE
|
||||
EnvironmentFile=/etc/default/webvirt
|
||||
|
||||
ExecStart=/bin/bash -c "cd ${WEBVIRT_PATH};${WEBVIRT_PATH}/venv/bin/python3 ${WEBVIRT_PATH}/console/socketiod"
|
||||
|
||||
# Make sure stderr/stdout is captured in the systemd journal.
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
WorkingDirectory=/srv/webvirtcloud
|
||||
EnvironmentFile=-/etc/default/webvirtcloud
|
||||
ExecStart=/srv/webvirtcloud/venv/bin/python3 /srv/webvirtcloud/console/socketiod
|
||||
# gunicorn stops its worker itself; the consoles end with their ptys
|
||||
KillMode=mixed
|
||||
Restart=on-failure
|
||||
RestartSec=10
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
|
|
|||
|
|
@ -4,16 +4,17 @@ Wants=network-online.target
|
|||
After=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
Restart=on-failure
|
||||
RestartSec=10
|
||||
User=www-data
|
||||
Group=www-data
|
||||
EnvironmentFile=/etc/default/webvirt
|
||||
ExecStart=/bin/bash -c "cd ${WEBVIRT_PATH}; WEBVIRTCLOUD_LOG_FILE=${WEBVIRT_PATH}/data/webvirtcloud-worker.log ${WEBVIRT_PATH}/venv/bin/python3 manage.py run_worker"
|
||||
WorkingDirectory=/srv/webvirtcloud
|
||||
EnvironmentFile=-/etc/default/webvirtcloud
|
||||
Environment=WEBVIRTCLOUD_LOG_FILE=/srv/webvirtcloud/data/webvirtcloud-worker.log
|
||||
ExecStart=/srv/webvirtcloud/venv/bin/python3 /srv/webvirtcloud/manage.py run_worker
|
||||
# the worker finishes its jobs for up to 60 s; its libvirt connections stay meanwhile
|
||||
KillMode=mixed
|
||||
TimeoutStopSec=90
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
Restart=on-failure
|
||||
RestartSec=10
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue