{"id":422,"date":"2011-07-04T14:37:26","date_gmt":"2011-07-04T06:37:26","guid":{"rendered":"http:\/\/www.myvoipapp.com\/blogs\/yxh\/?p=422"},"modified":"2019-02-12T20:11:53","modified_gmt":"2019-02-12T12:11:53","slug":"%e4%bd%bf%e7%94%a8python%e7%bc%96%e5%86%99%e7%ae%80%e5%8d%95%e7%9a%84%e5%ae%88%e6%8a%a4%e8%bf%9b%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/www.myvoipapp.com\/blogs\/yxh\/2011\/07\/04\/%e4%bd%bf%e7%94%a8python%e7%bc%96%e5%86%99%e7%ae%80%e5%8d%95%e7%9a%84%e5%ae%88%e6%8a%a4%e8%bf%9b%e7%a8%8b\/","title":{"rendered":"\u4f7f\u7528python\u7f16\u5199\u7b80\u5355\u7684\u5b88\u62a4\u8fdb\u7a0b"},"content":{"rendered":"<p>server\u7a0b\u5e8f\u4e0e\u684c\u9762\u7a0b\u5e8f\u6700\u57fa\u672c\u7684\u5dee\u522b\u5728\u4e8e\uff1aserver\u7a0b\u5e8f\u901a\u5e38\u9700\u8981\u66f4\u52a0\u7a33\u5b9a\u5730\u8fd0\u884c\uff0c\u6700\u597d\u662f\u6c38\u8fdc\u90fd\u4e0d\u4f1a\u4e2d\u65ad\uff0c\u786e\u4fdd\u670d\u52a1\u7684\u6301\u7eed\u6027\u3002<\/p>\n<p>\u8981\u505a\u5230\u8fd9\u70b9\uff0c\u9996\u5148\u5f53\u7136\u5e94\u5f53\u63d0\u9ad8\u7a0b\u5e8f\u672c\u8eab\u7684\u7a33\u5b9a\u6027\uff0c\u7a0b\u5e8f\u672c\u8eab\u5fc5\u987b\u8db3\u591f\u7a33\u5b9a\u624d\u6709\u610f\u4e49\u3002<\/p>\n<p>\u7136\u800c\uff0c\u5929\u6709\u4e0d\u6d4b\u98ce\u4e91\uff0c\u65e0\u8bba\u591a\u7b80\u5355\u7684\u8f6f\u4ef6\uff0c\u603b\u662f\u4f1a\u6709bug\uff0c\u4f1a\u6709\u53ef\u80fd\u5bfc\u81f4\u7a0b\u5e8fcrash\u3002\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u4ec5\u4ec5\u4f9d\u8d56\u63d0\u9ad8\u7a0b\u5e8f\u672c\u8eab\u7684\u7a33\u5b9a\u6027\u662f\u4e0d\u591f\u7684\u3002\u6211\u4eec\u8fd8\u9700\u8981\u53e6\u5916\u7684\u624b\u6bb5\u6765\u4fdd\u8bc1\u670d\u52a1\u7684\u6301\u7eed\u6027\u3002<\/p>\n<p>\u6700\u7b80\u5355\u7684\u529e\u6cd5\u5c31\u662f\u7528\u5b88\u62a4\u8fdb\u7a0b\u76d1\u89c6\u5f53\u524d\u7a0b\u5e8f\uff0c\u4e00\u65e6\u53d1\u751f\u5f02\u5e38\u6216\u8005crash\uff0c\u5c31\u91cd\u65b0\u542f\u52a8\u7a0b\u5e8f\u3002\u4f7f\u7528python\u5c31\u53ef\u4ee5\u7b80\u5355\u5730\u505a\u5230\u8fd9\u70b9\u3002<br \/>\n\u4f8b\u5982\uff0c\u6211\u4eec\u901a\u8fc7python\u811a\u672c(start_mss_app.py)\u6765\u76d1\u89c6msscli\u670d\u52a1\u7a0b\u5e8f\u7684\u8fd0\u884c\uff1a<\/p>\n<pre>\r\n#start_mss_app.py -- run and monitor msscli application\r\n\r\nimport os\r\nimport sys\r\n\r\nsys.path.append(\".\/\")\r\n\r\ndef monitor(appName):\r\n    pid = os.fork()\r\n\r\n    if 0 == pid:\t# child process\r\n        os.system(appName)\r\n        sys.exit(0)\r\n\r\n    else:  # parent process\r\n        os.wait()\r\n\r\nif __name__ == '__main__' :\r\n    while 1:\r\n        monitor('.\/msscli')<\/pre>\n<p>\u8fd0\u884c\u65f6\u5f88\u7b80\u5355\uff0c\u4f7f\u7528\u547d\u4ee4 python start_mss_app.py<strong> &amp; <\/strong>\u5373\u53ef\u3002<\/p>\n<p>\u5f53msscli\u7a0b\u5e8f\u53d1\u751f\u5f02\u5e38\u5bfc\u81f4crash\u6216\u8005\u9000\u51fa\u65f6\uff0cpython\u811a\u672c\u4f1a\u81ea\u52a8\u91cd\u8d77msscli\u7a0b\u5e8f\u3002<\/p>\n<p>\u5728\u8fdb\u884c\u7cfb\u7edf\u7ef4\u62a4\u6216\u8005\u5347\u7ea7\u65f6\uff0c\u6211\u4eec\u4e5f\u6709\u5fc5\u8981\u5f3a\u5236\u5173\u6389msscli\u670d\u52a1\u7a0b\u5e8f\uff0c\u6b64\u65f6\u7531\u4e8e\u4e0a\u8ff0\u5b88\u62a4\u8fdb\u7a0b\u7684\u5b58\u5728\uff0c\u6211\u4eec\u5148\u5fc5\u987bkill\u6389\u5b88\u62a4\u8fdb\u7a0b\uff0c\u7136\u540e\u624d\u80fdkill\u6389msscli\u670d\u52a1\u7a0b\u5e8f\uff1a<\/p>\n<p>sudo killall python<\/p>\n<p>sudo killall msscli<\/p>\n","protected":false},"excerpt":{"rendered":"<p>server\u7a0b\u5e8f\u4e0e\u684c\u9762\u7a0b\u5e8f\u6700\u57fa\u672c\u7684\u5dee\u522b\u5728\u4e8e\uff1aserver\u7a0b\u5e8f\u901a\u5e38\u9700\u8981\u66f4\u52a0\u7a33\u5b9a\u5730\u8fd0\u884c\uff0c\u6700\u597d\u662f\u6c38\u8fdc\u90fd\u4e0d\u4f1a\u4e2d\u65ad\uff0c\u786e\u4fdd\u670d\u52a1\u7684\u6301\u7eed\u6027\u3002 \u8981\u505a\u5230\u8fd9\u70b9\uff0c\u9996\u5148\u5f53\u7136\u5e94\u5f53\u63d0\u9ad8\u7a0b\u5e8f\u672c&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"https:\/\/www.myvoipapp.com\/blogs\/yxh\/2011\/07\/04\/%e4%bd%bf%e7%94%a8python%e7%bc%96%e5%86%99%e7%ae%80%e5%8d%95%e7%9a%84%e5%ae%88%e6%8a%a4%e8%bf%9b%e7%a8%8b\/\"> Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[157,158],"class_list":["post-422","post","type-post","status-publish","format-standard","hentry","category-6","tag-157","tag-158"],"_links":{"self":[{"href":"https:\/\/www.myvoipapp.com\/blogs\/yxh\/wp-json\/wp\/v2\/posts\/422","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.myvoipapp.com\/blogs\/yxh\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.myvoipapp.com\/blogs\/yxh\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.myvoipapp.com\/blogs\/yxh\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.myvoipapp.com\/blogs\/yxh\/wp-json\/wp\/v2\/comments?post=422"}],"version-history":[{"count":3,"href":"https:\/\/www.myvoipapp.com\/blogs\/yxh\/wp-json\/wp\/v2\/posts\/422\/revisions"}],"predecessor-version":[{"id":1888,"href":"https:\/\/www.myvoipapp.com\/blogs\/yxh\/wp-json\/wp\/v2\/posts\/422\/revisions\/1888"}],"wp:attachment":[{"href":"https:\/\/www.myvoipapp.com\/blogs\/yxh\/wp-json\/wp\/v2\/media?parent=422"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.myvoipapp.com\/blogs\/yxh\/wp-json\/wp\/v2\/categories?post=422"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.myvoipapp.com\/blogs\/yxh\/wp-json\/wp\/v2\/tags?post=422"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}