开发者

How do i start/stop a Rails app from Maven exec plugin?

I'm trying to start a Rails app from Maven exec plugin. I'm using ./script/rails server to start the server and kill -9 cat tmp/pids/server.pid to stop the server. But exec keeps waiting after server starts. Is it possible to ru开发者_StackOverflow社区n shell commands like this in background and not wait? Is there a better way to start/stop rails app from Maven? Here's my 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>


Pass the -d argument to start the server as a daemon: rails server -d.

Here's the details of the rails server command:

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.
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜