【问题标题】:Killing Processes Spawned by Foreman杀死工头产生的进程
【发布时间】:2013-12-10 00:09:43
【问题描述】:

我有以下Procfile

web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
redis: bundle exec redis-server /usr/local/etc/redis.conf
worker: bundle exec sidekiq

运行 $ foreman start 启动 Unicorn、Redis 和 Sidekiq,但我应该如何再次阻止它们?

杀死工头会让三个人都死掉。我可以使用ps 看到这一点:

$ ps aux | grep redis | grep -v grep
    me           61560   0.0  0.0  2506784   1740 s000  S+    9:36am   0:01.28 redis-server /usr/local/etc/redis.conf
$ ps aux | grep sidekiq  | grep -v grep
    me           61561   0.0  1.0  2683796 173284 s000  S+    9:36am   0:14.18 sidekiq 2.17.0 pathways [0 of 25 busy]
$ ps aux | grep unicorn | grep -v grep
    me           61616   0.0  0.2  2615284  28312 s000  S+    9:37am   0:00.06 unicorn worker[2] -p 5000 -c ./config/unicorn.rb
    me           61615   0.0  0.2  2615284  27920 s000  S+    9:37am   0:00.06 unicorn worker[1] -p 5000 -c ./config/unicorn.rb
    me           61614   0.0  0.2  2615284  27772 s000  S+    9:37am   0:00.06 unicorn worker[0] -p 5000 -c ./config/unicorn.rb
    me           61559   0.0  1.0  2615284 160988 s000  S+    9:36am   0:09.87 unicorn master -p 5000 -c ./config/unicorn.rb

显然我可以手动 kill 每个进程,但我怎样才能一次杀死所有进程呢?Foreman 似乎不支持这一点。

【问题讨论】:

    标签: ruby-on-rails ruby ruby-on-rails-3 foreman procfile


    【解决方案1】:

    或者你可以这样做

    $ killall "foreman: master"
    

    【讨论】:

      【解决方案2】:

      用一条线杀死他们:

      $ kill $(ps aux | grep -E 'redis|sidekiq|unicorn' | grep -v grep | awk '{print $2}')
      

      【讨论】:

      • 谢谢!这让我意识到 rails 端口不是我唯一需要杀死的!
      【解决方案3】:

      我不确定 Foreman 是否支持这一点。我使用subcontractor 并像这样使用它:

      web: subcontract --rbenv '1.9.3-p362' --chdir ../website --signal INT -- bundle exec thin start -p 3000

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2010-12-08
        相关资源
        最近更新 更多