开发者

How to start and stop a Sinatra application using Thin on Windows?

开发者 https://www.devze.com 2023-02-12 06:46 出处:网络
class App < Sinatra::Base def hello \"world\" end end From documentation I found tha开发者_StackOverflow中文版t I can start the application like this:
class App < Sinatra::Base
  def hello
    "world"
  end
end

From documentation I found tha开发者_StackOverflow中文版t I can start the application like this:

App.run

Although this does not return the control.

How do I start the application in the background and how can I then stop it.

My environment is: Windows, Ruby 1.9.2


Use a config.ru file like Dmitry Maksimov suggested:

#config.ru
require './your_app_file'

run YourApp

And then start with rackup -D which means deamonize and therefore it runs in the background.

I wouldn't recommend this for development though. Better have a look at Shotgun


Create in the top directory of your application rackup file - config.ru - with the following content:

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

require 'your app'
run Sinatra::Application

Then just run your app with the thin start

0

精彩评论

暂无评论...
验证码 换一张
取 消