From 9bfad485bee432263ccb6c565b9a06e12e5c749d Mon Sep 17 00:00:00 2001 From: Jens Vagelpohl Date: Wed, 8 May 2019 11:19:39 -0500 Subject: [PATCH] - added systemd integration information --- docs/operation.rst | 88 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 84 insertions(+), 4 deletions(-) diff --git a/docs/operation.rst b/docs/operation.rst index c0324ef05a..f79f75d512 100644 --- a/docs/operation.rst +++ b/docs/operation.rst @@ -116,7 +116,7 @@ In order to enable debug mode, you can add the additional ``-d`` or .. code-block:: console - $ bin/runwsgi -v etc/zope.ini -d + $ bin/runwsgi -dv etc/zope.ini Starting server in PID 55111. serving on http://127.0.0.1:8080 @@ -130,9 +130,48 @@ Now you are able to log in using a browser, as described in Running Zope as a Daemon ~~~~~~~~~~~~~~~~~~~~~~~~ -Zope has no built-in support for running as a daemon any more. You can -use projects like supervisord to achieve this or use your operating -system's built-in process manager. +Zope itself has no built-in support for running as a daemon any more. + +If you create your Zope instance using ``plone.recipe.zope2instance`` you can +use its start/stop script to daemonize Zope. See the next section for how to do +that. + +Alternatively, you can use projects like supervisord to achieve this or use +your operating system's built-in process manager, like ``systemd`` on most +Linux versions. As an example, the following ``systemd`` service configuration +works with the ``runwsgi`` script. It assumes your buildout is located at +``/opt/zopeinstance`` and the user account your Zope instance runs under is +``zope``: + +.. code-block:: cfg + + [Unit] + Description=Zope client zopeinstance + After=network.target + + [Service] + Type=simple + User=zope + ExecStart=/opt/zopeinstance/bin/runwsgi /opt/zopeinstance/etc/zope.ini + KillMode=control-group + TimeoutStartSec=10 + TimeoutStopSec=10 + + [Install] + WantedBy=multi-user.target + +Save this configuration under ``/etc/systemd/system/zopeinstance.service`` and +execute ``systemctl daemon-reload`` for ``systemd`` to read it. After that you +can use standard ``systemctl`` commands to start, restart or stop the Zope +instance: + +.. code-block:: console + + [root@server]# systemctl start zopeinstance + [root@server]# systemctl restart zopeinstance + [root@server]# systemctl status zopeinstance + [root@server]# systemctl stop zopeinstance + ... Debugging Zope @@ -219,6 +258,47 @@ Here's how to get status information and how to stop the Zope instance: daemon process stopped +To have your instance start automatically upon reboot, you will need to +integrate with your operating system's service startup facility. As an example, +the following ``systemd`` service configuration works with the start/stop +script generated by ``plone.recipe.zope2instance``. It assumes the script name +is ``zopeinstance``, your buildout is located at ``/opt/zopeinstance`` and the +user account your Zope instance runs under is ``zope``: + +.. code-block:: cfg + + [Unit] + Description=Zope client zopeinstance + After=network.target + + [Service] + Type=forking + User=zope + ExecStart=/opt/zopeinstance/bin/zopeinstance start + PIDFile=/opt/zopeinstance/var/zopeinstance/Z4.pid + ExecStop=/opt/zopeinstance/bin/zopeinstance stop + ExecReload=/opt/zopeinstance/bin/zopeinstance stop && /opt/zopeinstance/bin/zopeinstance start + KillMode=control-group + TimeoutStartSec=10 + TimeoutStopSec=10 + + [Install] + WantedBy=multi-user.target + +Save this configuration under ``/etc/systemd/system/zopeinstance.service`` and +execute ``systemctl daemon-reload`` for ``systemd`` to read it. After that you +can use standard ``systemctl`` commands to start, restart or stop the Zope +instance: + +.. code-block:: console + + [root@server]# systemctl start zopeinstance + [root@server]# systemctl restart zopeinstance + [root@server]# systemctl status zopeinstance + [root@server]# systemctl stop zopeinstance + ... + + Debugging Zope ~~~~~~~~~~~~~~ Debugging can be done at the command line: