# Keep eventmachine app running

**URL:** <https://www.ruby-forum.com/t/keep-eventmachine-app-running/189797>\
**Category:** Ruby\
**Created:** [June 7, 2010, 11:47pm UTC](https://www.ruby-forum.com/t/keep-eventmachine-app-running/189797 "2010-06-07T23:47:39Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![vect](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e480ec/32.png) [@vect](https://www.ruby-forum.com/u/vect)\
**Post date:** [June 7, 2010, 11:47pm UTC](https://www.ruby-forum.com/t/keep-eventmachine-app-running/189797/1 "2010-06-07T23:47:39Z")

</div>

I want to find out how to get a event machine app running in the  
background.

In example scripts I have seen when the script are executed it runs in  
the console but when the window/ssh session is closed the app stops.

What needs to be done to have the scripts running as a process in the  
background

---

<div class="post-metadata">

**Author:** ![vect](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e480ec/32.png) [@vect](https://www.ruby-forum.com/u/vect)\
**Post date:** [June 8, 2010, 12:25am UTC](https://www.ruby-forum.com/t/keep-eventmachine-app-running/189797/2 "2010-06-08T00:25:53Z")

</div>

Vect V. wrote:

> I want to find out how to get a event machine app running in the  
> background.
> 
> In example scripts I have seen when the script are executed it runs in  
> the console but when the window/ssh session is closed the app stops.
> 
> What needs to be done to have the scripts running as a process in the  
> background

A couple possibilities:

/usr/bin/nohup

/usr/bin/screen

nohup will allow the output to be logged to a file, and keep the  
process running when you disconnect.

screen will allow the actual ‘console’ to be preserved, so that  
you can reconnect to it later.

(The manpage for screen is lengthy and may appear a little daunting  
at first, but there are only a few concepts to learn to begin using  
screen. If you’re doing much work over ssh, it’s an extremely  
useful command.)

Hope this helps,

Bill

---

<div class="post-metadata">

**Author:** ![vect](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e480ec/32.png) [@vect](https://www.ruby-forum.com/u/vect)\
**Post date:** [June 8, 2010, 12:44am UTC](https://www.ruby-forum.com/t/keep-eventmachine-app-running/189797/3 "2010-06-08T00:44:36Z")

</div>

Bill K. wrote:

> A couple possibilities:  
> you can reconnect to it later.
> 
> (The manpage for screen is lengthy and may appear a little daunting  
> at first, but there are only a few concepts to learn to begin using  
> screen. If you’re doing much work over ssh, it’s an extremely  
> useful command.)

Those are ideal choices, particularly if you don’t want to touch the  
source code. If you want to write a program that just runs in the  
background with no need for screen or nohup, look into the various  
daemonize methods people have written in ruby.

---

<div class="post-metadata">

**Author:** ![vect](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e480ec/32.png) [@vect](https://www.ruby-forum.com/u/vect)\
**Post date:** [June 8, 2010, 1:01am UTC](https://www.ruby-forum.com/t/keep-eventmachine-app-running/189797/4 "2010-06-08T01:01:48Z")

</div>

What are some projects that do this and do they work with eventmachine

Joel VanderWerf wrote:

> Bill K. wrote:
> 
> > A couple possibilities:  
> > you can reconnect to it later.
> > 
> > (The manpage for screen is lengthy and may appear a little daunting  
> > at first, but there are only a few concepts to learn to begin using  
> > screen. If you’re doing much work over ssh, it’s an extremely  
> > useful command.)
> 
> Those are ideal choices, particularly if you don’t want to touch the  
> source code. If you want to write a program that just runs in the  
> background with no need for screen or nohup, look into the various  
> daemonize methods people have written in ruby.

---

<div class="post-metadata">

**Author:** ![vect](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e480ec/32.png) [@vect](https://www.ruby-forum.com/u/vect)\
**Post date:** [June 8, 2010, 1:17am UTC](https://www.ruby-forum.com/t/keep-eventmachine-app-running/189797/5 "2010-06-08T01:17:50Z")

</div>

Rein H. wrote:

> On 2010-06-07 14:47:49 -0700, Vect V. said:
> 
> > I want to find out how to get a event machine app running in the  
> > background.
> > 
> > In example scripts I have seen when the script are executed it runs in  
> > the console but when the window/ssh session is closed the app stops.
> > 
> > What needs to be done to have the scripts running as a process in the  
> > background
> 
> This is not strictly a Ruby question. It’s a \*nix question. The answers  
> already provided are sufficient, however:
> 
> A simple `ruby myscript.rb &` would also suffice, although process  
> control would then be more difficult.
> 
> The more complete and general way to handle such processes in the \*nix  
> world is the use of an init-like, like initd, runit or OS X’s launchd.

thanks guys.

I think screen is looking like a suitable solution

---

<div class="post-metadata">

**Author:** ![vect](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e480ec/32.png) [@vect](https://www.ruby-forum.com/u/vect)\
**Post date:** [June 8, 2010, 1:23am UTC](https://www.ruby-forum.com/t/keep-eventmachine-app-running/189797/6 "2010-06-08T01:23:50Z")

</div>

On Mon, Jun 7, 2010 at 5:01 PM, Vect V. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> What are some projects that do this and do they work with eventmachine

If you are writing the software, it’s simple. You should do a little  
background research, IMHO, so that you understand what daemonizing is.

[http://www.google.com/search?q=how+to+daemonize+a+process](http://www.google.com/search?q=how+to+daemonize+a+process)

Once you understand that, you can pretty easily write a little Ruby  
code to do a passable job yourself. There’s not much to it.

Or, you can use someone else’s project to do it:

gem search -r daemon

Take a look at some of those. Here’s one that has been around for a  
while:

[http://daemons.rubyforge.org/](http://daemons.rubyforge.org/)

Good luck!

Kirk H.

---

<div class="post-metadata">

**Author:** ![vect](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e480ec/32.png) [@vect](https://www.ruby-forum.com/u/vect)\
**Post date:** [June 8, 2010, 1:11am UTC](https://www.ruby-forum.com/t/keep-eventmachine-app-running/189797/7 "2010-06-08T01:11:32Z")

</div>

On 2010-06-07 14:47:49 -0700, Vect V. said:

> I want to find out how to get a event machine app running in the  
> background.
> 
> In example scripts I have seen when the script are executed it runs in  
> the console but when the window/ssh session is closed the app stops.
> 
> What needs to be done to have the scripts running as a process in the  
> background

This is not strictly a Ruby question. It’s a \*nix question. The answers  
already provided are sufficient, however:

A simple `ruby myscript.rb &` would also suffice, although process  
control would then be more difficult.

The more complete and general way to handle such processes in the \*nix  
world is the use of an init-like, like initd, runit or OS X’s launchd.
