Ubuntu下编写 goAgent 服务

字体大小: 中小 标准 ->行高大小: 标准

Ubuntu下编写 goAgent 服务

    #!/bin/sh       # goagent service by liuzhijun       start(){       echo "start goagent"         python /usr/local/share/goagent/local/proxy.py          exit 0      }       stop(){           echo "stop goagent"          ps -le |grep python |awk '{print $4}'| xargs kill -9   }          restart(){      echo "restart goagent"     stop      start    }       case "$1" in       start)       start       ;;    stop)       stop       ;;    restart)       restart       ;;    *)       echo "usage:$0 start|stop|restart"      exit 0;       esac  

几点说明:
0、goagent 是什么你懂的
1、在stop方法中不要写exit 0,否则在重启时,执行完stop方法后就退出了,没有机会执行start
2、编写完脚本后修改其属性为可执行 文件:  chmod a+x  goagent
3、此脚本是以杀掉所有Python进程来结束goagent进程,所以 如果系统中还运行有其他python的程序,此脚本不适用。
4、如果需要开机启动,可以执行命令:sudo update-rc.d goagent defaults 99
取消开机启动: sudo update-rc.d -f goagent remove

此文章由 http://www.ositren.com 收集整理 ,地址为: http://www.ositren.com/htmls/65643.html