Way to do ":background" without background?

32 views
Skip to first unread message

Carlos Peñas

unread,
Dec 18, 2015, 10:13:21 AM12/18/15
to Capistrano
Hi I needed to fire a long running and unrelated to deploy task on each deploy (and on demand) And I noticed a :background" method but it says it is deprecated, so it whouldn't work in a future version of SSHKit. 

Is there an alternative to launch a task on background without stop capistrano's processing?

I tried to launch with & but obviously, while there's a  job in the session capistrano won't continue.

Lee Hambley

unread,
Dec 18, 2015, 11:03:17 AM12/18/15
to Capistrano
First of all, well read - the `:background => true` is deprecated, because backgrounding things is hard, and unreliable, basically as you might have seen all it does it `nohup` and `&` if memory serves.

So there's two things you can do, the one - as you alluded to is `&` on the end of the line. The other would be `nohup` yourself, it'd be interesting to know *what* you are trying to background, as weird processes refuse to play well in the background in different ways.

Let's see if we can solve this for you :)

Carlos Peñas

unread,
Dec 18, 2015, 12:30:40 PM12/18/15
to Capistrano

On Friday, 18 December 2015 17:03:17 UTC+1, Lee Hambley wrote:
First of all, well read - the `:background => true` is deprecated, because backgrounding things is hard, and unreliable, basically as you might have seen all it does it `nohup` and `&` if memory serves.

Yes I noticed :) I Like to be informed before ask 

 
So there's two things you can do, the one - as you alluded to is `&` on the end of the line. The other would be `nohup` yourself, it'd be interesting to know *what* you are trying to background, as weird processes refuse to play well in the background in different ways.

The whole thing is to put "on background" a three line bash script that makes a "aws ec2 wait snapshot-completed" (no loops, no forks, no services, straight and simple thing that can work or not, but doesn't affect the deploy) and inform of the result by slack, for a snapshot that I asked to create in the previous commands of the capistrano task. The task just creates an snapshot of the deployed app EBS, but these snapshots sometimes take a bit to complete, that's why I want to "fire and forget" that script (it gives independent feedback, also)
 
Let's see if we can solve this for you :)

Well I'm very aware of the imitations of nohups, job control and the like, perhaps I can mimic the :background to get my own "non-deprecated" background and do my own tests. I know that fork processes over ssh conections can work for certain use cases, but cannot be guaranteed for all the use cases ;)

Thanks!

Lee Hambley

unread,
Dec 18, 2015, 1:07:51 PM12/18/15
to Capistrano
Alright, so sounds good :) At least if you know the risks, you can easily replicate "background => true" functionality yourself, and provided you know what's involved, the reasons we're deprecating it need not apply to you. As well you seem to know, nohup and & together are important, and so can be redirecting stdout/err to a file that isn't bound to the SSH TTY that Capistrano creates.

--
You received this message because you are subscribed to the Google Groups "Capistrano" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capistrano+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/capistrano/9c7e5aec-7a79-4326-80a8-713e34f0e00d%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages