Gunicorn Service
Output
# Define servo gunicorn service ( cat <<'EOF' [Unit] Description=servo gunicorn daemon Requires=servo.socket After=network.target [Service] PIDFile=/run/servo/pid User=ubuntu Group=ubuntu WorkingDirectory={{ working_directory }} ExecStart={{ python_venv }}/bin/gunicorn -c "python:hypertemplate.gunicorn" --pid /run/servo/pid --bind unix:/run/servo/socket ExecReload=/bin/kill -s HUP $MAINPID ExecStop=/bin/kill -s TERM $MAINPID PrivateTmp=true [Install] WantedBy=multi-user.target EOF ) >| /etc/systemd/system/servo.service # Define servo gunicorn socket ( cat <<'EOF' [Unit] Description=servo socket [Socket] ListenStream=/run/servo/socket [Install] WantedBy=sockets.target EOF ) >| /etc/systemd/system/servo.socket # Define servo gunicorn tmpfiles ( cat <<'EOF' d /run/servo 0755 ubuntu ubuntu - EOF ) >| /etc/tmpfiles.d/servo.conf # Define servo gunicorn sudo entries ( cat <<'EOF' ubuntu ALL=(ALL) NOPASSWD: /bin/systemctl start servo ubuntu ALL=(ALL) NOPASSWD: /bin/systemctl stop servo ubuntu ALL=(ALL) NOPASSWD: /bin/systemctl reload servo ubuntu ALL=(ALL) NOPASSWD: /bin/systemctl restart servo EOF ) >| /etc/sudoers.d/99-servo # Create tmpfiles systemd-tmpfiles --create # Reload systemd to see servo gunicorn entries systemctl daemon-reload # Enable servo gunicorn to autostart systemctl enable servo.socket