{"action":"created","issue":{"url":"https://api.github.com/repos/XX-net/XX-Net/issues/1773","labels_url":"https://api.github.com/repos/XX-net/XX-Net/issues/1773/labels{/name}","comments_url":"https://api.github.com/repos/XX-net/XX-Net/issues/1773/comments","events_url":"https://api.github.com/repos/XX-net/XX-Net/issues/1773/events","html_url":"https://github.com/XX-net/XX-Net/issues/1773","id":124356267,"number":1773,"title":"【需求】在linux下将xx-net做为后台服务启动","user":{"login":"Ozgay","id":7660045,"avatar_url":"https://avatars.githubusercontent.com/u/7660045?v=3","gravatar_id":"","url":"https://api.github.com/users/Ozgay","html_url":"https://github.com/Ozgay","followers_url":"https://api.github.com/users/Ozgay/followers","following_url":"https://api.github.com/users/Ozgay/following{/other_user}","gists_url":"https://api.github.com/users/Ozgay/gists{/gist_id}","starred_url":"https://api.github.com/users/Ozgay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ozgay/subscriptions","organizations_url":"https://api.github.com/users/Ozgay/orgs","repos_url":"https://api.github.com/users/Ozgay/repos","events_url":"https://api.github.com/users/Ozgay/events{/privacy}","received_events_url":"https://api.github.com/users/Ozgay/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-12-30T14:38:49Z","updated_at":"2016-01-08T00:38:20Z","closed_at":null,"body":"这是从goagent的proxy.sh脚本改的，我测试过可以用，请x大采纳。\r\n\r\n#1277 \r\n\r\n```\r\n#!/bin/sh\r\n#\r\n# xx_net init script\r\n#\r\n\r\n### BEGIN INIT INFO\r\n# Provides:          xx_net\r\n# Required-Start:    $syslog\r\n# Required-Stop:     $syslog\r\n# Should-Start:      $local_fs\r\n# Should-Stop:       $local_fs\r\n# Default-Start:     2 3 4 5\r\n# Default-Stop:      0 1 6\r\n# Short-Description: Monitor for xx_net activity\r\n### END INIT INFO\r\n\r\n# **NOTE** bash will exit immediately if any command exits with non-zero.\r\nset -e\r\n\r\nPACKAGE_NAME=xx_net\r\nPACKAGE_DESC=\"xx_net proxy server\"\r\nPATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:${PATH}\r\n\r\nstart() {\r\n    echo -n \"Starting ${PACKAGE_DESC}: \"\r\n    if hash python2 2>/dev/null; then\r\n        nohup python2 launcher/start.py 2>&1 | /usr/bin/logger -t ${PACKAGE_NAME} &\r\n    else\r\n        nohup python launcher/start.py 2>&1 | /usr/bin/logger -t ${PACKAGE_NAME} &\r\n    fi\r\n    echo \"${PACKAGE_NAME}.\"\r\n}\r\n\r\nstop() {\r\n    echo -n \"Stopping ${PACKAGE_DESC}: \"\r\n    if hash python2 2>/dev/null; then\r\n        kill -9 `ps aux | grep 'python2 launcher/start.py' | grep -v grep | awk '{print $2}'` || true\r\n    else\r\n        kill -9 `ps aux | grep 'python launcher/start.py' | grep -v grep | awk '{print $2}'` || true\r\n    fi\r\n    echo \"${PACKAGE_NAME}.\"\r\n}\r\n\r\nrestart() {\r\n    stop\r\n    sleep 1\r\n    start\r\n}\r\n\r\nusage() {\r\n    N=$(basename \"$0\")\r\n    echo \"Usage: [sudo] $N {start|stop|restart}\" >&2\r\n    exit 1\r\n}\r\n\r\nif [ \"$(id -u)\" != \"0\" ]; then\r\n    echo \"please use sudo to run ${PACKAGE_NAME}\"\r\n    exit 0\r\nfi\r\n\r\n# `readlink -f` won't work on Mac, this hack should work on all systems.\r\ncd $(python -c \"import os; print os.path.dirname(os.path.realpath('$0'))\")\r\n\r\ncase \"$1\" in\r\n    # If no arg is given, start the goagent.\r\n    # If arg `start` is given, also start goagent.\r\n    '' | start)\r\n        start\r\n        ;;\r\n    stop)\r\n        stop\r\n        ;;\r\n    #reload)\r\n    restart | force-reload)\r\n        restart\r\n        ;;\r\n    *)\r\n        usage\r\n        ;;\r\nesac\r\n\r\nexit 0\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/XX-net/XX-Net/issues/comments/169851607","html_url":"https://github.com/XX-net/XX-Net/issues/1773#issuecomment-169851607","issue_url":"https://api.github.com/repos/XX-net/XX-Net/issues/1773","id":169851607,"user":{"login":"xxnet","id":10395528,"avatar_url":"https://avatars.githubusercontent.com/u/10395528?v=3","gravatar_id":"","url":"https://api.github.com/users/xxnet","html_url":"https://github.com/xxnet","followers_url":"https://api.github.com/users/xxnet/followers","following_url":"https://api.github.com/users/xxnet/following{/other_user}","gists_url":"https://api.github.com/users/xxnet/gists{/gist_id}","starred_url":"https://api.github.com/users/xxnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xxnet/subscriptions","organizations_url":"https://api.github.com/users/xxnet/orgs","repos_url":"https://api.github.com/users/xxnet/repos","events_url":"https://api.github.com/users/xxnet/events{/privacy}","received_events_url":"https://api.github.com/users/xxnet/received_events","type":"User","site_admin":false},"created_at":"2016-01-08T00:38:20Z","updated_at":"2016-01-08T00:38:20Z","body":"​赞\r\n"}}