Use eventmachine with sinatra, why it will always quit?

why it always quit when i run this ruby program ? This is the ruby program:

require 'rubygems'
require 'eventmachine'
require 'thread'
require 'sinatra' do do
        EM.add_periodic_timer(1) do
            #do some things

get '/' do

when i run it, i got this:

lynn@ubuntu:~/Test$ ruby em1.rb 
== Sinatra/1.4.2 has taken the stage on 4567 for development with backup from Thin
>> Thin web server (v1.5.1 codename Straight Razor)
>> Maximum connections set to 1024
>> Listening on localhost:4567, CTRL+C to stop
lynn@ubuntu:~/Test$ netstat -ant
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0*               LISTEN     
tcp        0      0  *               LISTEN     
tcp        0      0    *               LISTEN     
tcp        0      0 *               LISTEN     
tcp       28      0        CLOSE_WAIT 
tcp        1      0         CLOSE_WAIT 
tcp6       0      0 :::22                   :::*                    LISTEN     
tcp6       0      0 ::1:631                 :::*                    LISTEN     

it was quit when i run this ruby program, why? here i wanna a thread to periodicaly do some things with the http request! how can i do it ?


Just run your Sinatra app under thin server and it will be fired with Eventmachine

Need Your Help

Problem with Cython, module import, and Pickling

python pickle cython

I use a custom random number generator build with Cython. I don't understand why, but it no longer works... I guess it is related to Python 2.7, or maybe a new version of Cython.

Detecting if an Internet Explorer process is running Flash Player

c# flash internet-explorer winapi process

Ok, here is a little 1 million dollars question. I'm developing an application that checks if any of your browsers is currently running a Flash application. Here is my core native implementation:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.