V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
supersheep
V2EX  ›  问与答

怎样作为子进程启动后台任务

  •  
  •   supersheep · 2013-09-28 14:58:55 +08:00 · 2638 次点击
    这是一个创建于 3869 天前的主题,其中的信息可能已经有所发展或是发生改变。
    就是我在做一个python的项目,写了个boot.sh去启动uwsgi
    后来我又写了一个grunt task来跑静态资源,于是boot.sh就变成了这样


    cd static
    grunt
    grunt watch
    cd ..
    uwsgi -s /tmp/uwsgi.sock --chmod-socket=666 -M -p 4 -t 60 --limit-as 128 -R 10000 --vhost

    然而这里的grunt watch会在那里等待监听文件变化,会卡住下面的事情。我只好把grunt watch改成 nohup grunt watch &

    不过这样一来,当我command+c退出uwsgi的时候grunt watch还会在那里。有没有什么办法可以让它也一起退出么?不行的话只能在最前面再ps -e|grep grunt然后找到进程杀一下了
    1 条回复    1970-01-01 08:00:00 +08:00
    supersheep
        1
    supersheep  
    OP
       2013-09-28 15:01:06 +08:00
    似乎fork就行了,让大家见笑了= =
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   791 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 58ms · UTC 22:01 · PVG 06:01 · LAX 15:01 · JFK 18:01
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.