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

Added sample systemd service file #54

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

szarka
Copy link
Contributor

@szarka szarka commented Dec 17, 2024

Added sample systemd service file patterned after bitcoind example file. Includes hardening options and comments with guide to expected file locations. Also creates contrib/init path in repo.

Possible enhancement would be to use Type=notify instead of Type=simple and wrap datum_gateway in a script that notifies systemd. But chose to stick with this simpler approach, as notification might better be implemented by datum_gateway itself.

@s0kil
Copy link

s0kil commented Dec 18, 2024

Great addition!

Wants=network-online.target
After=network-online.target
# alternatively, wait until bitcoind is up
#After=bitcoind.service
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, datum_gateway will fail to start if bitcoind isn't responsive - so maybe this should be uncommented?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it starts if bitcoind is unresponsive. It just doesn't do anything useful, except log a lot of errors. But the reason for leaving After=bitcoind.service line uncommented was simply that someone might be configuring datum to run via systemd without configuring bitcoind to run via systemd. But could leave it uncommented and have the comment say instead to remove it if bitcoind isn't configured via systemd.

contrib/init/datum_gateway.service Outdated Show resolved Hide resolved

Type=simple
NotifyAccess=all
PIDFile=/run/datum/datum_gateway.pid
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does systemd create the directory for us?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, systemd dynamically creates the directory on start and then deletes it on stop.

Group=datum

# /run/datum_gateway
RuntimeDirectory=datum_gateway
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't match PIDFile above

Copy link
Contributor Author

@szarka szarka Dec 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in the path for PIDFile. Would fix, but… Actually, PIDFile isn't even needed when running with Type=simple. Will delete PIDFile instead.

ConfigurationDirectoryMode=0710

# /var/lib/datum_gateway
StateDirectory=datum_gateway
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A case of me following the bitcoind example too closely, I think. Removing this section and replacing with LogsDirectory pointed at /var/log/datum_gateway instead.

@szarka
Copy link
Contributor Author

szarka commented Dec 21, 2024

OK, much cleaner version just pushed. I think the only unresolved question now is whether to uncomment After=bitcoind.service.

NGL, I miss pre-systemd init.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants