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

Running atomic-server as a service (auto-restart, start on boot) using systemd #271

Closed
1 task
joepio opened this issue Jan 4, 2022 · 5 comments
Closed
1 task

Comments

@joepio
Copy link
Member

joepio commented Jan 4, 2022

Since I wanted to start atomic-server whenever it crashes because of my memory issue #270, I created a systemd setup. Might be useful to others.

Also, I'm considering to add similar functionality to the server itself. Maybe add a setup-service or daemon subcommand that installs something like this.

How to make atomic-server a service

Create a service:

vim /etc/systemd/system/atomic.service

Paste this:

[Unit]
Description=Atomic-Server
#After=network.targetdd
StartLimitIntervalSec=0[Service]

[Service]
Type=simple
Restart=always
RestartSec=1
User=root
ExecStart=/root/atomic-server
WorkingDirectory=/root/
EnvironmentFil=/root/.env

[Install]
WantedBy=multi-user.target
# start service
systemctl run atomic
# check status
systemctl status atomic
# restart
systemctl restart atomic
# logs
journalctl -u atomic.service
# logs, since one hour, follow
journalctl -u atomic.service --since "1 hour ago" -f

TODO

  • Allow users to create a service description like above using a command like atomic-server service start. This could then setup the atomic.service file. We could also implement a restart and stop. We could use the systemd crate
@jonassmedegaard
Copy link

Nice. But wrong place to put it: Only the project author will generally read tickets in an issue tracker, whereas others (developers of related projects and users) will generally only write to the issue tracker.

Simplest way to (more likely, but not ensured) reach sysadmins is to mention this info in README.md.
More elegantly, however, is to include a file examples/atomic-server.service with the content and mention more briefly its existence in README.md.

Maybe there is more formal support in Rust crates to declare example files, or maybe even system config files, but lacking that, I recommend using directory examples as described above.

@jonassmedegaard
Copy link

Your systemd service unit file contains several typos, and is tailored for a service executed as root which is generally frowned upon.

I suggest taking inspiration from my file at https://salsa.debian.org/debian/atomic-data-rust/-/blob/debian/latest/debian/atomic-server.service if you decide to include a systemd service unit file as an example file with the project.

@joepio
Copy link
Member Author

joepio commented Mar 17, 2022

@jonassmedegaard agreed that an example in the repo is the way to go, as soon as one is good enough. I can't access the link you provided, can you directly post the .service here or (even better) open a PR?

@jonassmedegaard
Copy link

I can't access the link you provided

That's odd! That repo should certainly be public readable, and I just tested logging out from that Gitlab instance and could still read it.

What error message do you get, or in what other way does it fail for you?

can you directly post the .service here, or (even better) open a PR?

I won't push PRs to Github due to their problematic terms of service automatically granting them certain licensing implicitly by simply using their service.

So I would much prefer that you can access the Debian repo, as I might very well update data there.

@joepio
Copy link
Member Author

joepio commented Mar 17, 2022

There were some 500's coming from the gitlab instance, but it looks like that's resolved now. Anyways, looks good!

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

No branches or pull requests

2 participants