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

Bug: Background doesn't work as expected, should be deprecated and eventually removed #332

Open
leehambley opened this issue Feb 21, 2016 · 4 comments
Labels
Milestone

Comments

@leehambley
Copy link
Member

def background(*args)

The problem is that background simply nohup and backgrounds the process using the shell's job control &. More often than not, badly behaved daemons still block.

There's many hoops to jump through to ensure that your process behaves well when backgrounded, forked, nohupped, etc - and we can't whitelist programs that do it well, and blacklist those that can't.

Discussion is welcome, but I do think that background() should be removed from the DSL.

@mattbrictson
Copy link
Member

I agree. IMHO daemons should be managed by the init process, not by Capistrano deploy tasks. The background method is encouraging bad practice.

@leehambley
Copy link
Member Author

I agree. IMHO daemons should be managed by the init process, not by Capistrano deploy tasks.

Exactly, there's some legacy here, it used to be used for mongrel script/runner, and if you monitor a service with something like Monit, then starting it with Capistrano does make sense, sometimes.

@leehambley leehambley modified the milestone: 1.10.0 Mar 7, 2016
@mattbrictson mattbrictson modified the milestones: 1.10.0, 1.11.0 Apr 22, 2016
@maxwxzheng
Copy link

What's the suggested way to execute a command in background? Or is it discouraged?

@mattbrictson
Copy link
Member

What's the suggested way to execute a command in background? Or is it discouraged?

@maxwxzheng It is discouraged. SSHKit is typically used to deploy long-running processes, like app servers or job processors. In such a scenario, simply firing off the command in the background and hoping it stays running is not a good idea. What if the process dies? What if the server is rebooted? Instead, you should use a process manager like systemd which handles these things for you.

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

No branches or pull requests

3 participants