Systemd service template
Using the dispatcher systemd template allows you to run commands to stop and start the service using systemctl in Unix-like systems.
Systemd templates for the fastcgidispatch and httpdispatch dispatcher are provided in the FGLASDIR/systemd directory.
Warning:
The systemd files (.service ) contain the service
configuration options that allow you to control the dispatcher service via UNIX®
The systemd feature is available on Linux® only.
systemctl commands. The basic commands to use the service are provided; you may
want to adapt the template to suit your needs. For more information on working with systemd, see the
systemd documentation.An example of the systemd template for fastcgidispatch, fastcgidispatch.service,
is shown in the sample.
# Installed in the global system
#
# /lib/systemd/system/fastcgidispatch.service
# systemctl daemon-reload
# systemctl stop fastcgidispatch.service
# systemctl start fastcgidispatch.service
# systemctl status fastcgidispatch.service
#
# Installed in user space
#
# ~/.config/systemd/user/fastcgidispatch.service
# systemctl --user daemon-reload
# systemctl --user stop fastcgidispatch.service
# systemctl --user start fastcgidispatch.service
# systemctl --user status fastcgidispatch.service
[Unit]
Description=Genero Application Server 3.20.21-202304031114
After=network.target nss-lookup.target
Documentation=https://4js.com/online_documentation/fjs-gas-manual-html/
[Service]
Type=exec
Environment=FGLASDIR=/opt/fourjs/gas
ExecSearchPath=/opt/fourjs/gas/bin
ExecStart=fastcgidispatch -s
ExecStop=/bin/kill -s TERM $MAINPID
# KillMode=process -> only the dispatcher killed, proxies remain but many warnings in logs
# sessions remain valid if dispatcher restarts.
# KillMode=mixed -> dispatcher and proxies are killed -> all sessions lost.
KillMode=mixed
Restart=on-abort
RestartSec=15
SuccessExitStatus=SIGTERM 0
# If files are generated in /tmp and external apps expect to have access to it,
# either change PrivateTmp to false, or change the output directory for these files.
PrivateTmp=true
[Install]
WantedBy=multi-user.targetWhere:- Examples of the
systemctlcommands you can use to manage the service are included in the comments at the top of the file. - The configuration items are in the
[Unit],[Service], and[Install]sections. - The
ExecSearchPathparameter specifies the path to the dispatcher for the service. It affects where systemd looks for the commands specified inExecStart,ExecStop, and so one. This parameter was introduced in systemd version 250. If your version of systemd is earlier (runsystemctl --version), you will need to include the complete path to the dispatcher commands in theExec*parameters.
Usage
There are different ways of using the template depending on your requirements. You can either set
the service as a global service or as a user service. For this example we set the fastcgidispatch
service as a global system service:
- Copy the FGLASDI/systemd/fastcgidispatch.service service file to the /lib/systemd/system directory.
- Reload the systemd
configuration:
$ systemctl daemon-reload - Now you should be able to start and stop the dispatcher
service.
$ systemctl start fastcgidispatch.service $ systemctl stop fastcgidispatch.service - To configure the service to start automatically on boot, you need to
enableit:$ systemctl enable fastcgidispatch.service - To check the service logs,
run:
$ journalctl -u fastcgidispatch.service