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

RPM services fail after reboot on any system where /run is based on tmpfs #609

Closed
ekuns opened this issue Jun 23, 2015 · 4 comments
Closed

Comments

@ekuns
Copy link
Contributor

ekuns commented Jun 23, 2015

We have a service using systemd for its service in an RPM. Everything works. However, when you reboot the server, since /run (and thus /var/run) is based on tmpfs, the service's pid folder is gone on reboot. Thus, the service won't start. We have run into this on CentOS 7, which does not have the latest systemd. Therefore, the convenient solution of using

RuntimeDirectory=${{app_name}}
RuntimeDirectoryMode=755

in the systemd start template is not available. Another option is creating a file in /etc/tmpfiles.d/ that will auto-create the /run folder on every reboot. For example, if you create the file /etc/tmpfiles.d/${{app_name}} that contains just the one line:

d /var/run/ ${{app_name}} 0755 ${{daemon_user}} ${{daemon_group}}

We opted to add the following lines to the systemd start template:

ExecStartPre=/bin/mkdir -p /run/${{app_name}}
ExecStartPre=/bin/chown ${{daemon_user}}:${{daemon_group}} /run/${{app_name}}
ExecStartPre=/bin/chmod 755 /run/${{app_name}}
PermissionsStartOnly=true
@ekuns ekuns changed the title RPM services fail on any system where /run is based on tmpfs RPM services fail after reboot on any system where /run is based on tmpfs Jun 23, 2015
@muuki88
Copy link
Contributor

muuki88 commented Jun 23, 2015

Thanks for detailed report. SystemD is still somewhat experimental so we really appreciate sharing your solutions here.

This sounds similar to #610 your solution looks solid to me. We have something similar for systemv/debian. A pull request would be awesome :)

See https://github.com/sbt/sbt-native-packager/blob/master/src/main/resources/com/typesafe/sbt/packager/archetypes/java_server/systemloader/systemv/start-debian-template

@ekuns
Copy link
Contributor Author

ekuns commented Jun 23, 2015

I can make a pull request. It may take a day or two, but shouldn't be a big deal. I just corrected my post above to add missing $ for ${{app_name}} -- silly typo on my part.

@ekuns
Copy link
Contributor Author

ekuns commented Jun 23, 2015

I updated my post above to add detail on the possible /etc/tmpfiles.d/ solution, which may help out with the Debian version. (I'm assuming they use tmpfiles.d?) We tested that solution and it worked perfectly. But it meant adding another file to our solution instead of making small changes to a file we already had.

@ekuns
Copy link
Contributor Author

ekuns commented Jun 24, 2015

Pull request created -- #611 -- I don't know how to link it to this issue.

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

No branches or pull requests

2 participants