Skip to content

Commit

Permalink
Add systemd unit file and README.systemd explanation
Browse files Browse the repository at this point in the history
Merged from koniu/recoll-webui#55
Add a sample systemd script in examples and a README describing how to
integrate the standalone WebUI app with systemd.
Author: Rob Fair <[email protected]>
  • Loading branch information
medoc92 committed Oct 2, 2019
1 parent b694521 commit d8d5fea
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,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 standalone application can be configured to run automatically using
systemd. See the file README.systemd.

Run as WSGI/CGI
---------------

Expand Down
77 changes: 77 additions & 0 deletions README.systemd
Original file line number Diff line number Diff line change
@@ -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
35 changes: 35 additions & 0 deletions examples/recoll-webui.service
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d8d5fea

Please sign in to comment.