-
-
Notifications
You must be signed in to change notification settings - Fork 239
Description
Describe the bug
i'm not exactly sure whether this is an issue with pywb, but investigating systemd's and gunicorn's documentation leaves me with the impression that they do their job.
when starting a systemd service that controls a gunicorn process which in turn shall serve pywb, systemd doesn't recognize the process as started, though the process and the expected children are running and responding. after the timeout, systemd tries to start the service again. at this point the associated socket file vanishes and the service becomes unreachable.
just running gunicorn works fine, which would rather imply that it is an issue w/ systemd. but on the other hand, what it does is simple and known to work.
Steps to reproduce the bug
-
install pywb in a virtual environment
-
install gunicorn in the same venv
-
create a data dir for pywb, add
config.yml, init a collection nameddefault -
add
wayback.service,wayback.socketand/etc/tmpfiles.daccording to gunicorn's docs, reload the systemd-daemon -
systemctl start wayback.socket -
curl --unix-socket /run/wayback/socket httpyields expected html content -
wait a minute
-
curl --unix-socket /run/wayback/socket httpyieldscurl: (7) Couldn't connect to server -
following
journalctl -fregularly prints something like this:
gunicorn[21929]: [2018-10-10 15:11:27 +0200] [21929] [INFO] Shutting down: Master
systemd[1]: wayback.service: Failed with result 'timeout'.
systemd[1]: Failed to start Wayback server.
systemd[1]: wayback.service: Service hold-off time over, scheduling restart.
systemd[1]: wayback.service: Scheduled restart job, restart counter is at 5.
systemd[1]: Stopped Wayback server.
systemd[1]: Starting Wayback server...
gunicorn[21999]: [2018-10-10 15:11:28 +0200] [21999] [INFO] Starting gunicorn 19.9.0
gunicorn[21999]: [2018-10-10 15:11:28 +0200] [21999] [INFO] Listening at: unix:/run/wayback/socket (21999)
gunicorn[21999]: [2018-10-10 15:11:28 +0200] [21999] [INFO] Using worker: gevent
gunicorn[21999]: [2018-10-10 15:11:28 +0200] [22017] [INFO] Booting worker with pid: 22017
gunicorn[21999]: [2018-10-10 15:11:28 +0200] [22018] [INFO] Booting worker with pid: 22018
gunicorn[21999]: [2018-10-10 15:11:28 +0200] [22022] [INFO] Booting worker with pid: 22022
gunicorn[21999]: [2018-10-10 15:11:28 +0200] [22026] [INFO] Booting worker with pid: 22026
gunicorn[21999]: [2018-10-10 15:11:28 +0200] [22029] [INFO] Booting worker with pid: 22029
gunicorn[21999]: [2018-10-10 15:11:28 +0200] [22033] [INFO] Booting worker with pid: 22033
gunicorn[21999]: [2018-10-10 15:11:28 +0200] [22034] [INFO] Booting worker with pid: 22034
gunicorn[21999]: [2018-10-10 15:11:28 +0200] [22036] [INFO] Booting worker with pid: 22036
Expected behavior
Environment
- OS: Ubuntu 18.04
Additional context
config.yml:
---
enable_http_proxy: true
proxy_options:
use_default_coll: default
framed_replay: false # okay, as long as trusted sites are archived/etc/systemd/system/wayback.service:
[Unit]
Description=Wayback server
Requires=wayback.socket
After=network.target
[Service]
Type=forking
Restart=always
PIDFile=/run/wayback/pid
WorkingDirectory=/var/lib/pywb
RuntimeDirectory=wayback
User=archivist
ExecStart=/usr/local/share/virtualenv/pywb/bin/gunicorn --workers 8 --worker-class gevent --bind unix:/run/wayback/socket --pid /run/wayback/pid pywb.apps.wayback
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
/etc/systemd/system/wayback.socket:
[Unit]
Description=wayback socket
[Socket]
ListenStream=/run/wayback/socket
[Install]
WantedBy=sockets.target
/etc/tmpfiles.d/wayback:
d /run/wayback 0755 archivist archivist -