-
Notifications
You must be signed in to change notification settings - Fork 443
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
SystemV init script is not idempotent #451
Comments
Thanks for the detailed bug report! What are the difference between your solutions? Using the start-stop-daemon --background \
--chdir ${{chdir}} --chuid "$DAEMON_USER" \
--make-pidfile --pidfile "$PIDFILE" \
--startas "$RUN_CMD" --start -- $RUN_OPTS The second solution, using exec -a ${{app_name}} "$@" What would you suggest? PRs welcome :) |
Hi, thanks for the fast feedback! Yes, you described it correctly. I generally would prefer the second solution ( I was not sure which solution would be more idiomatic for the SBT plugin, so I decided to just create an issue. Also I was not sure whether i understand the problem correctly (or missing some obvious solution) - judging by the scope of this issue, I would assume that many people should potentially face it. But if we agree on some particular solution, I can make a PR. |
Using Happy to merge your PR. Nice avatar btw ;) |
Thanks :) Ok, I will try to test the change with our setup tomorrow, and if everything works fine, i will make a PR. |
…pt idempotent. This will only use PID file to check whether application is started or not. `--exec` in contrast is also checks the `/proc/[PID]/exe` file which links to the java executable and not original start script (see [this article](https://chris-lamb.co.uk/posts/start-stop-daemon-exec-vs-startas)). For more detail please see the discussion on sbt#451
…pt idempotent. This will only use PID file to check whether application is started or not. `--exec` in contrast is also checks the `/proc/[PID]/exe` file which links to the java executable and not original start script (see [this article](https://chris-lamb.co.uk/posts/start-stop-daemon-exec-vs-startas)). For more detail please see the discussion on #451
I'm creating a debian package with SystemV (init.d) init script in it. The problem is that I able to
sudo service my-app start
several times in a row and it will start several processes. I expect it to start my service the first time and fail all consequent starts because service is already started and running.The actual issue is in the way services are started. It uses
--exec
here:The problem is that in order to check whether the service is running,
--exec
not only checks the PID file, but also the/proc/[PID]/exe
file (see this article for more detail). This is a problem, because the actual process is ajava
process, but what I give to thestart-stop-daemon
command is an application name likemy-service
.I looked at this issue and found 2 possible solutions. One would be to use
--startas
instead of--exec
like described in article I linked above. Another solution would be to useexec -a <actual-service-name> "$@"
in the application script:https://github.com/sbt/sbt-native-packager/blob/master/src/main/resources/com/typesafe/sbt/packager/archetypes/bash-template#L136
in order to change the process name.
The text was updated successfully, but these errors were encountered: