我在使用薄,与EventMachine的运行其他任务的模块化西纳特拉Web应用程序运行。
它的工作原理,但里面的东西有点古怪的Web服务器:任何要求,无论是成功还是404,不会出现在从薄/西纳特拉输出日志。 当我取消的过程中,服务器端的两倍。
下面是该应用程序的粗糙,基本结构:
Procfile:
web: ruby app.rb
app.rb:
require 'thin'
require 'eventmachine'
require 'app/frontend'
EM.run do
# Start some background tasks here...
EM.add_periodic_timer(1200) do
# Do a repeating task here...
end
App::Frontend.run!
end
应用程序/ frontend.rb:
require 'sinatra/base'
module App
class Frontend < Sinatra::Base
get '/' do
# Display page
end
# etc
end
end
当我做foreman start
然后我得到:
16:50:00 web.1 | started with pid 76423
16:50:01 web.1 | [messages about EventMachine background tasks starting]
16:50:01 web.1 | == Sinatra/1.4.3 has taken the stage on 5000 for development with backup from Thin
16:50:01 web.1 | >> Thin web server (v1.5.1 codename Straight Razor)
16:50:01 web.1 | >> Maximum connections set to 1024
16:50:01 web.1 | >> Listening on 0.0.0.0:5000, CTRL+C to stop
没有更多的是输出,当我要求现有的网页(其中加载OK)或不存在的网页。 当我取消的过程中,我得到:
^CSIGINT received
16:50:08 system | sending SIGTERM to all processes
SIGTERM received
16:50:08 web.1 | >> Stopping ...
16:50:08 web.1 | == Sinatra has ended his set (crowd applauds)
16:50:08 web.1 | >> Stopping ...
16:50:08 web.1 | == Sinatra has ended his set (crowd applauds)
16:50:08 web.1 | exited with code 0
这西纳特拉完成两次让我觉得我莫名其妙地跑了两次,而这服务于网页中的一个没有被记录......但我不知道我如何管理这个!