我正在尝试从Maven exec插件启动Rails应用程序。我正在使用./script/rails server
启动服务器,kill -9 cat tmp/pids/server.pid
停止服务器。但是exec在服务器启动后一直在等待。是否有可能在后台运行这样的shell命令而不是等待?有没有更好的方法从Maven启动/停止rails应用程序?这是我的pom.xml:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>start-rails-app</id>
<phase>pre-integration-test</phase>
<configuration>
<executable>script/rails</executable>
<workingDirectory>${rails.app.dir}</workingDirectory>
<arguments>
<argument>server</argument>
</arguments>
</configuration>
<goals>
<goal>exec</goal>
</goals>
</execution>
<execution>
<id>stop-rails-app</id>
<phase>post-integration-test</phase>
<configuration>
<executable>kill -9 `cat tmp/pids/server.pid`</executable>
<workingDirectory>${rails.app.dir}</workingDirectory>
</configuration>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>
答案 0 :(得分:1)
传递-d
参数以作为守护程序启动服务器:rails server -d
。
以下是rails server
命令的详细信息:
rails server -h
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: 0.0.0.0
-c, --config=file Use custom rackup configuration file
-d, --daemon Make server run as a Daemon.
-u, --debugger Enable ruby-debugging for the server.
-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 Show this help message.