Sinatra 做簡單的ruby Server

ruby寫一個簡單的備份Server

最近有一個需求 就是用ruby寫一個簡單的備份Server

但是如果利用Rails來做的話, 就會覺得簡單的功能,用Rails 反而覺得太複雜了

所以就用Sinatra

Sinatra在背景執行

nohup ruby web.rb >> log/file 2>&1 &

關閉執行的sinatra程序

方式1:
File.open('myapp.pid', 'w') {|f| f.write Process.pid }

shell: kill `cat myapp.pid`

ruby: Process.kill 'TERM', File.read('myapp.pid’)
方式2:
ps aux | grep ruby $ kill <ruby-process-id>

Leave a Reply

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax