开发者

Can I do Sinatra program without restart server?

When I modify the code and have to restart server to see results. Hav开发者_StackOverflow中文版e any way out?


There are a few options, detailed in the Sinatra FAQ. The simplest appears to be to use shotgun, which you can install and invoke as follows:

$ sudo gem install shotgun
$ shotgun myapp.rb

or if you use define your app by inheriting from Sinatra::Base and use a config.ru file:

$ shotgun config.ru -p 4567


If you use Phusion Passenger, you can put this file in the application’s root folder

tmp/always_restart.txt

and it will restart on every request.

http://www.modrails.com/documentation/Users%20guide%20Apache.html ( section 8.7 )


Better way is to use reloader from sinatra-contrib gem (also from Sinatra FAQ): First install sinatra-contrib gem, then ensure your application .rb file starts with these lines:

require 'sinatra'
require 'sinatra/reloader' if development?

And then any modified config files will be reloaded (no need to restart server!)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜