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

Run from systemd unit file. #12

Open
Doty1154 opened this issue Apr 2, 2023 · 3 comments
Open

Run from systemd unit file. #12

Doty1154 opened this issue Apr 2, 2023 · 3 comments

Comments

@Doty1154
Copy link

Doty1154 commented Apr 2, 2023

Hey I'm trying to run this from a systemd unit file on a up to date ubuntu server.
I previously used https://github.com/marcsello/minecraftd
So it's running from a specific user account and directory.
It sounds like the binary doesn't not like running from systemd for some reason. However if i run it manually from the "minecraft" user account in the /opt/minecraft folder your program works without issue(cool!)
Here's the issue i get for the systemd unit with debug systemd turned on:

Apr 02 02:59:29 minecraft systemd[1]: mc-server-wrapper.service: Will spawn child (service_enter_start): /opt/minecraft/.cargo/bin/mc-server-wrapper
Apr 02 02:59:29 minecraft systemd[1]: mc-server-wrapper.service: Passing 0 fds to service
Apr 02 02:59:29 minecraft systemd[1]: mc-server-wrapper.service: About to execute /opt/minecraft/.cargo/bin/mc-server-wrapper
Apr 02 02:59:29 minecraft systemd[1]: mc-server-wrapper.service: Forked /opt/minecraft/.cargo/bin/mc-server-wrapper as 1527
Apr 02 02:59:29 minecraft systemd[1]: mc-server-wrapper.service: Changed dead -> running
Apr 02 02:59:29 minecraft systemd[1]: mc-server-wrapper.service: Job 4668 mc-server-wrapper.service/start finished, result=done
Apr 02 02:59:29 minecraft systemd[1]: Started mc-server-wrapper.
░░ Subject: A start job for unit mc-server-wrapper.service has finished successfully
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ A start job for unit mc-server-wrapper.service has finished successfully.
░░
░░ The job identifier is 4668.
Apr 02 02:59:29 minecraft systemd[1]: mc-server-wrapper.service: User lookup succeeded: uid=997 gid=998
Apr 02 02:59:29 minecraft systemd[1527]: mc-server-wrapper.service: Executing: /opt/minecraft/.cargo/bin/mc-server-wrapper
Apr 02 02:59:29 minecraft mc-server-wrapper[1527]: Error: Resource temporarily unavailable (os error 11)
Apr 02 02:59:29 minecraft systemd[1]: mc-server-wrapper.service: Child 1527 belongs to mc-server-wrapper.service.
Apr 02 02:59:29 minecraft systemd[1]: mc-server-wrapper.service: Main process exited, code=exited, status=1/FAILURE

Here is my systemd unit file, I've tried different types, using simple and then not specifying it. I also tried specifying kill mode/killsignal and not using these options.

[Unit]
Description=mc-server-wrapper
After=network-online.target

[Service]
Type=simple
ExecStart=/opt/minecraft/.cargo/bin/mc-server-wrapper
WorkingDirectory=/opt/minecraft
Restart=always
User=minecraft
Group=minecraft
KillMode=process
KillSignal=SIGINT

[Install]
WantedBy=multi-user.target

@Cldfire
Copy link
Owner

Cldfire commented Apr 16, 2023

Hmm, interesting!

The best bit of information about what's going on is in this log line:

Apr 02 02:59:29 minecraft mc-server-wrapper[1527]: Error: Resource temporarily unavailable (os error 11)

Looking around the internet, I see a wide variety of possibilities for what that could mean.

Are there any logs from mc-server-wrapper itself you can share? Any kind of panic / backtrace information?

@Doty1154
Copy link
Author

Hey, i know it's been a while since i posted. But. I got this working by simply using screen to open mc-server-wrapper in a active terminal session. I believe your package just exits once it sees that it's not running interactively(?) At least this is my theory.
I think long term maybe adding a -D flag or something where there isn't a tui but just a background process would be great in the future : )

Here's the config i'm using rn.. It doesn't exit appropriately so systemd ends up waiting like 2 minutes during shutdown and kills the process.. that sucks.. I'm not enough of a systemd wizard to figure out a better solution : p


[Unit]
Description=mc-server-wrapper
After=network-online.target


[Service]
Type=simple
ExecStart=screen -D -m /opt/minecraft/.cargo/bin/mc-server-wrapper
WorkingDirectory=/opt/minecraft
Restart=always
User=minecraft
Group=minecraft
KillMode=process
KillSignal=SIGCONT
RestartSec=30

[Install]
WantedBy=multi-user.target

@Cldfire
Copy link
Owner

Cldfire commented Feb 10, 2024

Oh neat!

If I ever spend time on this project again I'll look into cleaning that up. I haven't played MC for a while so I don't have much of a reason to work on this tool.

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