【问题标题】:How to start and stop a Sinatra application using Thin on Windows?如何在 Windows 上使用 Thin 启动和停止 Sinatra 应用程序?
【发布时间】:2011-07-01 19:13:16
【问题描述】:
class App < Sinatra::Base
  def hello
    "world"
  end
end

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

App.run

虽然这不会返回控件。

如何在后台启动应用程序以及如何停止它。

我的环境是:Windows,Ruby 1.9.2

【问题讨论】:

  • 退货控制是什么意思?就像在命令提示符下?此外,您拥有的代码还远远不能工作
  • thin 甚至可以在 Windows 上运行吗?

标签: ruby windows sinatra thin


【解决方案1】:

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

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

require 'your app'
run Sinatra::Application

然后只需使用thin start 运行您的应用程序

【讨论】:

  • thin start 似乎控制住了,它似乎没有在后台运行。
【解决方案2】:

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

#config.ru
require './your_app_file'

run YourApp

然后以 rackup -D 开头,这意味着 deamonize,因此它在后台运行。

不过,我不建议将其用于开发。最好看看Shotgun

【讨论】:

  • deamonize 后如何阻止它?
  • code.macournoyer.com/thin/usage 我现在无法检查。但是thin start -C ... 与配置文件的组合和 deamonizing 应该让您有可能用类似 thin stop -C ... 的东西来阻止它
猜你喜欢
  • 1970-01-01
  • 2011-12-09
  • 1970-01-01
  • 2012-01-27
  • 1970-01-01
  • 2015-03-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多