-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
AWS remote exec and HUP signal killing initd service #5113
Comments
@byrnedo it sounds like you're using a In most cases that should be fine, as long as the init script is correctly written and the service itself is properly "daemonizing"... which includes steps such as detaching from the shell's process group, disconnecting from the controlling terminal, etc. Are you able to reproduce the same symptom if you SSH in directly and start the service, before logging out? If so, I would expect that the above is the problem: the service in question isn't fully daemonizing, and so when the launching shell exits the service is killed. In that case, how to resolve this unfortunately depends entirely on what service you're running, although a general solution for running un-cooperative programs as long-running services is to run it under some sort of daemon supervisor like supervisord or damontools. In that case, it is the supervisor program that "daemonizes", and the target service is expected not to daemonize... it remains as a child process of the supervisor program and running in the "foreground" from its perspective, and the supervisor program monitors to ensure it stays running. Modern init replacements in Linux distributions often have a mechanism for this built in. For example, both upstart and systemd expect "foregrounded" applications by default, and only with additional settings will expect a program to actively daemonize itself. At work we're now a 100% systemd environment, and so very few of our programs actually daemonize themselves and in most cases we just let systemd supervise them. When using such a "supervisor" system, whether an add-on one or one built in to your main init system, you can then use I hope something in all of that was helpful. If you think your problem is not what I've described here, it'd help to have a bit more info on exactly what service you're trying to run. |
Hi @apparentlymart and thanks for the thorough reply! The thing is that when manually ssh'ing onto the box, starting the service and then logging off, it works fine. I am interacting with the service using (on ubuntu) 'service ' via a remote exec. I believe it's upstart which is running on my box, not systemd. The provisioner line:
What actually ends up working for me is forcing it to ssh manually from a local-exec:
I'm not too well versed in these things but is it something to do with creating a shell session? Again, thanks for your exhaustive reply. Further info: the service is rexray. The init.d script that
|
@byrnedo I guess the main question now then is what is different about how Terraform is internally using a native Go SSH implementation rather than running the I found rexray/rexray#85, which seems to be old and resolved but the discussion in there did give me a lead: it would appear that rexray is sensitive to whether or not it's running in a pseudo-tty. IIRC, We could attempt to confirm this by taking your working Unfortunately I don't think Terraform currently provides a way to disable the pseudo-tty creation, so if this is the problem then the immediate solution would be to try to insulate rexray from the problem. (more on that below) If the pseudo-tty doesn't seem to be the problem then I think a solution will come from further investigating differences between the I don't know upstart well, but based on my experience with systemd I'd guess that upstart is running that init script in some sort of "initscript emulation mode", since upstart's native service definition is a different format. You may be able to get more control over how rexray launches by writing a first-class upstart configuration for it. A quick skim of the
I'll need to defer to the upstart docs for the details on that, but if upstart is similar to systemd then I expect upstart would then be able to run this program in a more controlled fashion, isolated from the environment where you're running the |
I think your first assumption is right. I did the following
And it appears to not have started. I'll try out rolling my own upstart script, I had hoped I could avoid doing this but it's not that bad really. There's no way to force terraform to use native ssh? |
Cool... I'm glad we got to the bottom of that. Sorry it ended up being a bit of a "busy-work" solution but hopefully it works out well. r.e. using the OpenSSH client, using the |
That's grand, I can make do with that. Thanks for all the help! |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
When running an initd command on ubuntu 14.04, my service ends up getting killed once the ssh session exits. Is there a way to prevent this? It appears to receive a HUP signal.
The text was updated successfully, but these errors were encountered: