Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Systemd support for standalone WebUI app #55

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
---------------

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