Skip to the content
Documentation

Setting up the asynchronous publishing service with an in...

No ratings yet

On a production server the publishing daemon should start with the server and be restarted when it stops. Exponential ships init scripts for that, and the daemon can also run as a systemd service.

With the shipped init scripts

The scripts are in bin/startup/: debian/ezasynchronouspublisher for Debian and Ubuntu, rhel/ezasynchronouspublisher for Red Hat Enterprise Linux, AlmaLinux, Rocky Linux and Fedora. Link the one for your system into /etc/init.d/. The name of the link is free, so several installations can have a daemon each:

cd /etc/init.d
ln -s /var/www/example/bin/startup/debian/ezasynchronouspublisher ezasynchronouspublisher-example
/etc/init.d/ezasynchronouspublisher-example start

The Debian script accepts start, stop, restart and force-reload; the Red Hat script also reload, status, condrestart and try-restart. Each script finds the installation from the path of the script, runs the daemon with -n as the user RUN_AS_USER, and keeps the PID file in /var/run/Exponential/. The daemon script bin/php/ezasynchronouspublisher.php must be executable, as it is shipped.

Configuring the init script

The defaults are in ezasynchronouspublisher.defaults next to the script: RUN_AS_USER=www-data, and PHP_EXECUTABLE when PHP is not on that user's PATH. Do not edit that file, an upgrade replaces it. Copy it instead:

System For every daemon For one daemon (the name of the link)
Debian, Ubuntu /etc/default/ezasynchronouspublisher.conf /etc/default/ezasynchronouspublisher/<name>.conf
Red Hat and related /etc/ezasynchronouspublisher.conf /etc/ezasynchronouspublisher/<name>.conf
cp bin/startup/debian/ezasynchronouspublisher.defaults /etc/default/ezasynchronouspublisher.conf

The files are read in that order, the defaults first, so a later file wins.

With systemd

On a system that uses systemd, a service that runs the daemon in the foreground (without -n) lets systemd start, stop and restart it. An example, with the path, user and PHP binary of your installation:

# /etc/systemd/system/ezasynchronouspublisher-example.service
[Unit]
Description=Exponential asynchronous publishing daemon (example)
After=network.target mariadb.service

[Service]
User=www-data
WorkingDirectory=/var/www/example
ExecStart=/usr/bin/php bin/php/ezasynchronouspublisher.php
Restart=on-failure

[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl enable --now ezasynchronouspublisher-example

In the foreground the daemon writes its output to standard output, which the journal keeps (journalctl -u ezasynchronouspublisher-example).

See Various configurations for how many daemons a setup needs.

Contributors

Comments

Add a comment

Comments are read by a moderator before they appear.