From cc528181572303ef977ee3149ced0e1410004e3e Mon Sep 17 00:00:00 2001 From: Recoll Index Date: Fri, 7 Oct 2016 08:31:55 -0400 Subject: [PATCH 1/2] Add systemd.service config --- examples/recoll-webui.service | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 examples/recoll-webui.service diff --git a/examples/recoll-webui.service b/examples/recoll-webui.service new file mode 100644 index 0000000..92a2b1d --- /dev/null +++ b/examples/recoll-webui.service @@ -0,0 +1,35 @@ +# SystemD script for running the standalong server as a daemon +# Place this in /etc/systemd/system/recoll-webui.servivce +# owned by root, mode 0644 + +# This assumes the Recoll Web-UI is installed under +# the path /home/recoll/recoll-webui, and runs against port 8080. +# Change these below as needed. +# +[Unit] +Description=Recoll Search WebUI + +After=network.target + +RequiresMountsFor=/home/recoll + +[Service] +# Standalone server runs as the main job, default +Type=simple + +# Run under user recoll +User=recoll + +# Set listen port and address as needed. +# %H is the current host name +ExecStart=/home/recoll/recoll-webui/webui-standalone.py \ + -a %H \ + -p 8080 + +ExecStop=/bin/kill -SIGINT $MAINPID +KillMode=process + +Restart=on-failure + +[Install] +WantedBy=multi-user.target From 5879ea69222bb1e67dbaf8fbcc935eb91fba7cc2 Mon Sep 17 00:00:00 2001 From: Rob Fair Date: Sat, 8 Oct 2016 21:53:53 -0400 Subject: [PATCH 2/2] Add README for systemd configuration --- README.rst | 3 ++ README.systemd | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 README.systemd diff --git a/README.rst b/README.rst index bb3c4f9..d70ea41 100644 --- a/README.rst +++ b/README.rst @@ -46,6 +46,9 @@ There's some optional command-line arguments available:: -a ADDR, --addr ADDR address to bind to [127.0.0.1] -p PORT, --port PORT port to listen on [8080] +The standalong application can be configured to run automatically using systemd. See the +file README.systemd. + Run as WSGI/CGI --------------- diff --git a/README.systemd b/README.systemd new file mode 100644 index 0000000..eebae3b --- /dev/null +++ b/README.systemd @@ -0,0 +1,77 @@ +Using the standalone WebUI application with systemd +--------------------------------------------------- +This README describes how to configure systemd so that the +standalone WebUI application can run automatically as a systemd service. + +Before doing this, ensure that the standalone application runs OK +when run from the command line, and that it is *not* configured to +be run as part of an existing web service, e.g. Apache. + +Systemd configuration script +---------------------------- +A sample systemd configuration script for the WebUI application is +in examples/recoll-webui.service. This assumes the following configuration: + +- The WebUI application runs as user 'recoll', with the WebUI source located + in /home/recoll/recoll-webui. +- The application should listen on the default IP address for the system. +- The application uses port 8080. + +If any of these are different for your installation, change the +configuration script accordingly. + +Installing the configuration script +----------------------------------- +The configuration script must be copied to the systemd directory +and given the correct ownership/access . This can be done using: + + $ sudo cp examples/recoll-webui /etc/systemd/system/recoll-webui + $ sudo chown root /etc/systemd/system/recoll-webui + $ sudo chmod 644 /etc/systemd/system/recoll-webui + +Starting the WebUI service +-------------------------- +To start the WebUI service do: + + $ sudo systemctl start recoll-webui + +This does a one-time start of the service. If you want to automatically start the +service at boot, also do: + + $ sudo systemctl enable recoll-webui + +Checking the status of the WebUI service +---------------------------------------- +Check the status of the WebUI service with: + + $ sudo systemctl status recoll-webui + +If it is running you should see output similar to this: + + recoll-webui.service - Recoll Search WebUI + Loaded: loaded (/etc/systemd/system/recoll-webui.service; enabled; vendor preset: disabled) + Active: active (running) since Fri 2016-10-07 08:46:00 EDT; 1 day 12h ago + Process: 16278 ExecStop=/bin/kill -SIGINT $MAINPID (code=exited, status=0/SUCCESS) + Main PID: 16281 (python) + CGroup: /system.slice/recoll-webui.service + └─16281 python /home/recoll/recoll-webui/webui-standalone.py -a myhost -p 8080 + +This shows the status of the standalone application, along with the command line that +was used. + +Stopping the WebUI service +-------------------------- +To stop the WebUI service do: + + $ sudo systemctl stop recoll-webui + +To disable the service so it does not run at boot time do: + + $ sudo systemctl disable recoll-webui + +Restarting the WebUI service +---------------------------- +The WebUI configuration script is set to automatically restart the +standalone application if it fails. You can also manually restart it using: + + $ sudo systemctl restart recoll-webui