【问题标题】:How do i start/stop a Rails app from Maven exec plugin?如何从 Maven exec 插件启动/停止 Rails 应用程序?
【发布时间】:2011-02-26 00:16:50
【问题描述】:

我正在尝试从 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>

【问题讨论】:

    标签: ruby-on-rails shell deployment maven exec


    【解决方案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.
    

    【讨论】:

      猜你喜欢
      • 2019-02-14
      • 1970-01-01
      • 1970-01-01
      • 2010-11-02
      • 2013-01-09
      • 1970-01-01
      • 1970-01-01
      • 2018-09-15
      • 1970-01-01
      相关资源
      最近更新 更多