如何在Windows上使用Thin启动和停止Sinatra应用程序?

Pra*_*man 6 ruby windows thin sinatra

class App < Sinatra::Base
  def hello
    "world"
  end
end
Run Code Online (Sandbox Code Playgroud)

从文档中我发现我可以像这样启动应用程序:

App.run
Run Code Online (Sandbox Code Playgroud)

虽然这不会返回控件.

如何在后台启动应用程序,然后如何停止它.

我的环境是:Windows,Ruby 1.9.2

sca*_*ble 7

使用像Dmitry Maksimov建议的config.ru文件:

#config.ru
require './your_app_file'

run YourApp
Run Code Online (Sandbox Code Playgroud)

然后开始使用rackup -Ddeamonize,因此它在后台运行.

我不建议将其用于开发.最好看看Shotgun


Dmi*_*mov 6

在应用程序rackup文件的顶级目录中创建 - config.ru - 具有以下内容:

# config.ru
$: << File.expand_path(File.dirname(__FILE__))

require 'your app'
run Sinatra::Application
Run Code Online (Sandbox Code Playgroud)

然后用你的应用程序运行 thin start

  • 瘦启动似乎控制住了,它似乎并没有在后台运行. (2认同)