zoukankan      html  css  js  c++  java
  • [转] How to kill ruby on rails WEBrick server daemon

    How to kill ruby on rails WEBrick server daemon

    I have been running a rails app on a machine, which I can’t restart (no root access) or physically pull the plug on, just using the prepackaged rails server, WEBrick. But I quickly found out that it was not that easy to kill my app. I’d run something like script/server -d -p 25000 > /dev/null . 
    Notice that -d puts the server in daemon mode and > /dev/nullsends all the standard out to /dev/null .
    I tried to kill the app using top and then killing with the process ID, then tried pgrep and kill on the command line, to no avail.

    Finally I found the (simple) solution that I’ll repost here. On the command line of the machine running the server:

    pgrep ruby

    This will give you the process id of the rails app (assuming you don’t have another ruby app running). Note: if pgrep is not available on your machine try using the command:

    top

    and look for the id of a process called ‘ruby’.

    Now kill that process using the command:

    kill -9 [id]

    Where [id] is the process id given by pgrep.

    Update:
    It seems kill -9 may be jumping the gun and perhaps you ought to be safe and follow the advice I found elsewhere. 
    I’ll reiterate his point here. After finding the process id using prgepissue the following commands waiting five seconds before trying the next one until the kill succeeds:

    kill pid
    kill pid
    kill
    -INT [id]
    kill
    -INT [id]
    kill
    -KILL [id]
    kill
    -KILL [id]

    Notice that -KILL is the same as -9 .

  • 相关阅读:
    51nod 1067 Bash游戏 V2
    洛谷 P1454 圣诞夜的极光 == codevs 1293 送给圣诞夜的极光
    bzoj4754: [Jsoi2016]独特的树叶
    bzoj 4241: 历史研究
    bzoj 1266 [AHOI2006] 上学路线
    bzoj4571: [Scoi2016]美味
    bzoj4570: [Scoi2016]妖怪
    51nod 1238 最小公倍数之和 V3
    一个康托展开的板子
    poweroj1745: 餐巾计划问题
  • 原文地址:https://www.cnblogs.com/JulyZhang/p/1991709.html
Copyright © 2011-2022 走看看