Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

class App < Sinatra::Base
  def hello
    "world"
  end
end

From documentation I found that 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

like image 898
Prakash Raman Avatar asked Feb 22 '11 07:02

Prakash Raman


2 Answers

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

like image 181
scable Avatar answered Sep 18 '22 22:09

scable


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

like image 30
Dmitry Maksimov Avatar answered Sep 17 '22 22:09

Dmitry Maksimov