views:

101

answers:

3

I am trying to develop a rails metal endpoint using sinatra, but is proving to be a pain because I have to restart the server every time I change the code. I am in Jruby and running from within a larger Java app. Is there an easy way to make this code refresh for every request?

+1  A: 

I don't think there is a way to automatically reload sinatra code, however:

If you were running passenger, you could try running in irb:

 loop do
   `touch tmp/restart.txt`
   sleep(1)
 end

Which will then tell the passenger instance to restart the application.

Ryan Bigg
A: 

Just because I like abstract abstraction, this is Ryan's code v2:

def every s
  loop do
    sleep s
    yield
  end
end

every 1 { `touch tmp/restart.txt` }
Justice
A: 

Guys, I'm working with a JRuby on Rails project, and I'm running into a similar problem. It's not fun to restart a JRuby mongrel server every time I update a view file (since for some reason JRuby on Rails doesn't refresh view files when you change them). I'm assuming our friend is not using passenger, since he said he is running within a Java server. If I find the solution to this problem I'll let you know, but so far I can't find any comment or blog entry or documentation regarding refreshing without restarting.

thekingoftruth
this is insightful and helpful, but it should have been posted as a comment, not an answer. you can simply click "add comment" under the answer to add such information. thank you.
yuval
I agree with your suggestion, however I don't have enough reputation to comment on someone else's question yet.
thekingoftruth