14
MBPro:shovell myname$ ruby script/server
=> Booting WEBrick
=> Rails 2.3.8 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2010-08-01 15:28:35] INFO  WEBrick 1.3.1
[2010-08-01 15:28:35] INFO  ruby 1.9.1 (2010-07-02) [i386-darwin10.4.0]
[2010-08-01 15:28:35] INFO  WEBrick::HTTPServer#start: pid=36349 port=3000

このコマンドの後、私はターミナルを開いたままにしなければならず、Cmd+zを使用して出ることさえできません。バックグラウンドサービスとして実行できませんか?

ありがとう

4

4 に答える 4

38

出力はすでにあなたに答えを与えています:

=> Call with -d to detach
于 2010-08-01T10:11:01.843 に答える
6

一般に、次のものを使用できます。

command &

そして、端末ウィンドウから切り離されます。

Linux を使用している場合、別のオプションとして以下を使用できますscreen

screen
# start your process
# press Ctrl+a
# press Ctrl+d

出来上がり!離れています。その後、電話をかけるscreen -rと、何も起こらなかったかのようにプロセスが元に戻ります。

于 2010-08-01T10:15:38.873 に答える
2

実行rails s --help すると、たくさんのオプションが表示されます

Usage: rails server [mongrel, thin etc] [options]
    -p, --port=port                  Runs Rails on the specified port.
                                     Default: 3000
    -b, --binding=IP                 Binds Rails to the specified IP.
                                     Default: localhost
    -c, --config=file                Uses a custom rackup configuration.
    -d, --daemon                     Runs server as a Daemon.
    -u, --debugger                   Enables the debugger.
    -e, --environment=name           Specifies the environment to run this server under (test/development/production).
                                     Default: development
    -P, --pid=pid                    Specifies the PID file.
                                     Default: tmp/pids/server.pid

    -h, --help                       Shows this help message.

必要なのは、デーモンとして実行することです。したがって、解決策は次のとおりです。 rails s -d

于 2016-01-13T05:41:15.003 に答える
1

mongrel gem はこれを簡単に行うことができます。

gem install mongrel

次に、使用できるはずです

mongrel_rails start -d

-dデーモンモード用。

于 2010-08-01T10:14:52.333 に答える