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
Restart=always not working with ExecStopPost and dependency on service with StopWhenUnneeded=true #1154
Comments
Which systemd version is this happening with? |
I run version 224. |
same issue on centos 7.2 running version 219. Is there any fix or workaround ? |
Has the problem been solved? |
No. Just tested it with version v238-76-gf398c546c (f398c54). Still same behavior. |
Ok thanks! Do you know any other way to get know when s systemd service
restart ? Because I'm now trying to figure out if the application somehow
silently failed and got respawned by systemd, or whether a user purposely
restarted the service via systemctl.(Which Restart=always) Thank you very
much.
…On Thu, May 3, 2018 at 5:37 PM, omgold ***@***.***> wrote:
No. Just tested it with version v238-76-gf398c546c (
f398c54). Still same behavior.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1154 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/Aiqns4XzMXOdMzhrTNyvV8p1fjkRb-2Mks5tus_agaJpZM4F4ZXP>
.
--
*Amy Yu*
*TVU Networks*
1279, ZhongShan Road West, Building 6, 10th floor
<https://maps.google.com/?q=1279,+ZhongShan+Road+West,+Building+6,+10th+floor&entry=gmail&source=g>
Shanghai, P.R.China
amyyu@tvunetworks.com
*Making every transmission a success*
www.tvunetworks.com
Facebook <https://www.facebook.com/TVUNetworks/> | Twitter
<https://twitter.com/TVUNetworks> | Instagram
<https://www.instagram.com/tvu_networks/> | LinkedIn
<https://www.linkedin.com/in/carolinemccarty/>
|
@omgold You have StopWhenUnneeded=true in myd2.service, you have Requires=myd2.service in myd1.service, Requires= forwards stop/restart requests on required unit to requiree, so when you go down, what happens is that the other unit has a stop job triggered from systemd due to referenced units not being active anymore, meanwhile, your ExecStopPost= keeps it hung in deactivating stage for a while. OTOH, this stop job on myd2.service is propagated to your unit back when it was triggered. This creates a race: now, when the stop job installs itself in your unit, the state change (to failed) is attributed to it. Since Restart= only triggers when state change happens without any job's involvement, it will not fire a restart job for the same unit. Fix is to probably introduce a version of Requires= that only has the strong effect at start and not propagation effect like PartOf=. |
@omgold Note that your bug was fixed with a3c1168 so this works in v240 nicely. @poettering This can be closed. |
ping |
In found that in a special situation a service is not restarted, although marked as Restart=always. I narrowed it down to the combination of the two service files below.
If I do a kill -9 on the sleep command of myd2 the service enters failed state instead of restarting. But if I remove either the StopWhenUnneeded from myd1 or the ExecStopPost from myd2 it works as expected.
I believe this is a bug.
--- myd1.service ---
[Unit]
Description=example daemon 1
StopWhenUnneeded=true
[Service]
Type=oneshot
ExecStart=/bin/true
ExecStop=/bin/true
RemainAfterExit=true
--- myd2.service ---
[Unit]
Description=example daemon 2
Requires=myd1.service
After=myd1.service
[Service]
Type=simple
ExecStart=/usr/bin/sleep 100000000
ExecStopPost=/bin/true
Restart=always
The text was updated successfully, but these errors were encountered: