Page MenuHomePhorge

Document a systemd daemon
Closed, ResolvedPublic

Description

This is a very basic systemd daemon that I use in my production and would be awesome to document somewhere:

/etc/systemd/system/phorge-phd.service
[Unit]
Description=Phorge Daemons asd
After=syslog.target network.target mariadb.service

[Service]
Type=forking
User=phorge
Group=phorge
ExecStart=/var/www/phorge/bin/phd start
ExecStop=/var/www/phorge/bin/phd stop

[Install]
WantedBy=multi-user.target

To install that:

systemctl daemon-reload
systemctl enable phorge-phd
systemctl start  phorge-phd

For example here:

https://we.phorge.it/book/phorge/article/managing_daemons/

We can surely continue to do not document this, but it's not that strategic, since systemd is literally what now every distribution on the planet (except two) have.

Event Timeline

This is a nice contribution and definitely would be a valuable addition to the docs, IMO.

That said, I wonder if we should also consider supporting a world where systemd owns the individual daemons instead of having PHD do all the work.

It might make sense when running under systemd to actually have individual service unit for each of the daemons, using Type=simple instead of Type=forking

For example:

[Unit]
Description=Phorge Repository Daemon
After=syslog.target network.target mariadb.service

[Service]

Type=simple 
KillMode=process
Restart=always

User=phorge
Group=phorge

WorkingDirectory=/var/www/phorge/
ExecStart=/var/www/phorge/bin/phd debug PhabricatorRepositoryPullLocalDaemon

I'm not sure that it ever made sense for Phabricator to implement all of the daemon management logic. think it makes even less sense today than it ever did, especially in a systemd environment.

Note: If we were to properly support something like this then we'd want to implement something similar to the 'debug' command but without the verbose logging that debug mode enables.

Partially related, a systemd unit for the SSH server. Proposal in D25497