class App < Sinatra::Base
def hello
"world"
end
end
从文档中我发现可以这样启动应用程序:
App.run
虽然这不会返回控制权。
如何在后台启动应用程序,以及如何停止它。
我的环境是:Windows,Ruby 1.9.2
class App < Sinatra::Base
def hello
"world"
end
end
从文档中我发现可以这样启动应用程序:
App.run
虽然这不会返回控制权。
如何在后台启动应用程序,以及如何停止它。
我的环境是:Windows,Ruby 1.9.2
#config.ru
require './your_app_file'
run YourApp
接下来,使用rackup -D
命令开始运行,这意味着它将以守护进程的方式在后台运行。
我并不推荐在开发过程中使用此方法。最好使用Shotgun工具。
thin start -C ...
组合应该可以让你像这样停止它:thin stop -C ...
。 - scable# config.ru
$: << File.expand_path(File.dirname(__FILE__))
require 'your app'
run Sinatra::Application
接着只需使用thin start
命令运行您的应用程序即可。