{"id":47804,"date":"2024-12-02T17:41:35","date_gmt":"2024-12-02T09:41:35","guid":{"rendered":"https:\/\/fwq.ai\/blog\/47804\/"},"modified":"2024-12-02T17:41:35","modified_gmt":"2024-12-02T09:41:35","slug":"pheanstalk-%e6%b6%88%e6%81%af%e9%98%9f%e5%88%97%e5%a6%82%e4%bd%95%e8%ae%be%e7%bd%ae%e5%90%8e%e5%8f%b0%e6%b6%88%e8%b4%b9%e8%80%85%e6%89%a7%e8%a1%8c%e6%b6%88%e6%81%af%e5%a4%84%e7%90%86%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/47804\/","title":{"rendered":"Pheanstalk \u6d88\u606f\u961f\u5217\u5982\u4f55\u8bbe\u7f6e\u540e\u53f0\u6d88\u8d39\u8005\u6267\u884c\u6d88\u606f\u5904\u7406\uff1f"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>Pheanstalk \u6d88\u606f\u961f\u5217\u5982\u4f55\u8bbe\u7f6e\u540e\u53f0\u6d88\u8d39\u8005\u6267\u884c\u6d88\u606f\u5904\u7406\uff1f<\/h1>\n<p><span style=\"cursor: pointer\"><i><\/i>\u6536\u85cf<\/span> <\/p>\n<p>\u5bf9\u4e8e\u4e00\u4e2a\u6587\u7ae0\u5f00\u53d1\u8005\u6765\u8bf4\uff0c\u7262\u56fa\u624e\u5b9e\u7684\u57fa\u7840\u662f\u5341\u5206\u91cd\u8981\u7684\uff0c\u7c73\u4e91\u5c31\u6765\u5e26\u5927\u5bb6\u4e00\u70b9\u70b9\u7684\u638c\u63e1\u57fa\u7840\u77e5\u8bc6\u70b9\u3002\u4eca\u5929\u672c\u7bc7\u6587\u7ae0\u5e26\u5927\u5bb6\u4e86\u89e3\u300aPheanstalk \u6d88\u606f\u961f\u5217\u5982\u4f55\u8bbe\u7f6e\u540e\u53f0\u6d88\u8d39\u8005\u6267\u884c\u6d88\u606f\u5904\u7406\uff1f\u300b\uff0c\u4e3b\u8981\u4ecb\u7ecd\u4e86\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff0c\u5feb\u70b9\u6536\u85cf\u8d77\u6765\u5427\uff0c\u5426\u5219\u9700\u8981\u65f6\u5c31\u627e\u4e0d\u5230\u4e86\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241026\/1729937206671cbf36d9ac7.jpg\" class=\"aligncenter\" title=\"Pheanstalk \u6d88\u606f\u961f\u5217\u5982\u4f55\u8bbe\u7f6e\u540e\u53f0\u6d88\u8d39\u8005\u6267\u884c\u6d88\u606f\u5904\u7406\uff1f\u63d2\u56fe\" alt=\"Pheanstalk \u6d88\u606f\u961f\u5217\u5982\u4f55\u8bbe\u7f6e\u540e\u53f0\u6d88\u8d39\u8005\u6267\u884c\u6d88\u606f\u5904\u7406\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>beanstalkd \u6d88\u8d39\u8005\u540e\u53f0\u6267\u884c<\/strong><\/p>\n<p>pheanstalk \u6d88\u606f\u961f\u5217\u5141\u8bb8\u60a8\u8bbe\u7f6e\u540e\u53f0\u6d88\u8d39\u8005\u6765\u5904\u7406\u6d88\u606f\u3002\u8981\u4f7f\u6d88\u8d39\u8005\u4ee3\u7801\u5728\u540e\u53f0\u5b89\u9759\u5730\u8fd0\u884c\uff0c\u800c\u4e0d\u5fc5\u76f4\u63a5\u8c03\u7528\u6d88\u8d39\u8005\u65b9\u6cd5\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\uff1a<\/p>\n<p><strong>\u540e\u53f0\u8fdb\u7a0b<\/strong><\/p>\n<p>\u6700\u7b80\u5355\u7684\u65b9\u6cd5\u662f\u4f7f\u7528\u540e\u53f0\u8fdb\u7a0b\u6765\u542f\u52a8\u6d88\u8d39\u8005\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u884c\u547d\u4ee4\u4ee5\u540e\u53f0\u65b9\u5f0f\u542f\u52a8 php \u811a\u672c\uff1a<\/p>\n<pre>nohup php xxxx<\/pre>\n<p>\u6216\u8005<\/p>\n<pre>setsid php xxxx<\/pre>\n<p><strong>supervisor<\/strong><\/p>\n<p>supervisor \u662f\u4e00\u4e2a\u7528\u4e8e\u7ba1\u7406\u540e\u53f0\u8fdb\u7a0b\u7684\u5de5\u5177\u3002\u5b83\u63d0\u4f9b\u4e86\u591a\u79cd\u542f\u52a8\u548c\u505c\u6b62\u9009\u9879\uff0c\u4ee5\u53ca\u65e5\u5fd7\u8bb0\u5f55\u548c\u9519\u8bef\u62a5\u544a\u529f\u80fd\u3002\u8981\u4f7f\u7528 supervisor \u8fd0\u884c\u6d88\u8d39\u8005\uff0c\u60a8\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a supervisor \u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<pre>[program:pheanstalk-consumer]\ncommand=\/usr\/local\/bin\/php \/path\/to\/consumer.php\nstdout_logfile=\/var\/log\/pheanstalk-consumer.log\nstderr_logfile=\/var\/log\/pheanstalk-consumer-error.log\nuser=www-data<\/pre>\n<p><strong>linux systemd<\/strong><\/p>\n<p>\u5982\u679c\u60a8\u4f7f\u7528\u7684\u662f linux \u7cfb\u7edf\uff0c\u53ef\u4ee5\u4f7f\u7528 systemd \u6765\u7ba1\u7406\u540e\u53f0\u8fdb\u7a0b\u3002\u8981\u4f7f\u7528 systemd \u8fd0\u884c\u6d88\u8d39\u8005\uff0c\u60a8\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a systemd \u5355\u5143\u6587\u4ef6\uff1a<\/p>\n<pre>[unit]\ndescription=pheanstalk consumer\nafter=network.target\n\n[service]\ntype=simple\nexecstart=\/usr\/local\/bin\/php \/path\/to\/consumer.php\nrestart=on-failure\n\n[install]\nwantedby=multi-user.target<\/pre>\n<p>\u4fdd\u5b58\u6b64\u6587\u4ef6\u5e76\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\u5b83\uff1a<\/p>\n<pre>sudo systemctl daemon-reload\nsudo systemctl enable pheastalk-consumer.service<\/pre>\n<p>\u4e00\u65e6\u914d\u7f6e\u597d\u540e\u53f0\u8fdb\u7a0b\uff0c\u60a8\u5c31\u53ef\u4ee5\u542f\u52a8\u6d88\u8d39\u8005\u5e76\u8ba9\u5b83\u5728\u540e\u53f0\u5b89\u9759\u5730\u8fd0\u884c\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u300aPheanstalk \u6d88\u606f\u961f\u5217\u5982\u4f55\u8bbe\u7f6e\u540e\u53f0\u6d88\u8d39\u8005\u6267\u884c\u6d88\u606f\u5904\u7406\uff1f\u300b\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u5173\u4e8e\u7684\u8d44\u6599\u8bf7\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff01<\/p>\n<p> \u7248\u672c\u58f0\u660e \u672c\u6587\u8f6c\u8f7d\u4e8e\uff1aphp \u5982\u6709\u4fb5\u72af\uff0c\u8bf7\u8054\u7cfb \u5220\u9664<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Pheanstalk \u6d88\u606f\u961f\u5217\u5982\u4f55\u8bbe\u7f6e\u540e\u53f0\u6d88\u8d39\u8005\u6267\u884c\u6d88\u606f\u5904\u7406\uff1f \u6536\u85cf \u5bf9\u4e8e\u4e00\u4e2a\u6587\u7ae0\u5f00\u53d1\u8005\u6765\u8bf4\uff0c\u7262\u56fa\u624e\u5b9e\u7684\u57fa\u7840\u662f\u5341\u5206\u91cd\u8981\u7684\uff0c\u7c73\u4e91\u5c31\u6765\u5e26\u5927\u5bb6\u4e00\u70b9\u70b9\u7684\u638c\u63e1\u57fa\u7840\u77e5\u8bc6\u70b9\u3002\u4eca\u5929\u672c\u7bc7\u6587\u7ae0\u5e26\u5927\u5bb6\u4e86\u89e3\u300aPheanstalk \u6d88\u606f\u961f\u5217\u5982\u4f55\u8bbe\u7f6e\u540e\u53f0\u6d88\u8d39\u8005\u6267\u884c\u6d88\u606f\u5904\u7406\uff1f\u300b\uff0c\u4e3b\u8981\u4ecb\u7ecd\u4e86\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff0c\u5feb\u70b9\u6536\u85cf\u8d77\u6765\u5427\uff0c\u5426\u5219\u9700\u8981\u65f6\u5c31\u627e\u4e0d\u5230\u4e86\uff01 beanstalkd \u6d88\u8d39\u8005\u540e\u53f0\u6267\u884c pheanstalk \u6d88\u606f\u961f\u5217\u5141\u8bb8\u60a8\u8bbe\u7f6e\u540e\u53f0\u6d88\u8d39\u8005\u6765\u5904\u7406\u6d88\u606f\u3002\u8981\u4f7f\u6d88\u8d39\u8005\u4ee3\u7801\u5728\u540e\u53f0\u5b89\u9759\u5730\u8fd0\u884c\uff0c\u800c\u4e0d\u5fc5\u76f4\u63a5\u8c03\u7528\u6d88\u8d39\u8005\u65b9\u6cd5\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\uff1a \u540e\u53f0\u8fdb\u7a0b \u6700\u7b80\u5355\u7684\u65b9\u6cd5\u662f\u4f7f\u7528\u540e\u53f0\u8fdb\u7a0b\u6765\u542f\u52a8\u6d88\u8d39\u8005\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u884c\u547d\u4ee4\u4ee5\u540e\u53f0\u65b9\u5f0f\u542f\u52a8 php \u811a\u672c\uff1a nohup php xxxx \u6216\u8005 setsid php xxxx supervisor supervisor \u662f\u4e00\u4e2a\u7528\u4e8e\u7ba1\u7406\u540e\u53f0\u8fdb\u7a0b\u7684\u5de5\u5177\u3002\u5b83\u63d0\u4f9b\u4e86\u591a\u79cd\u542f\u52a8\u548c\u505c\u6b62\u9009\u9879\uff0c\u4ee5\u53ca\u65e5\u5fd7\u8bb0\u5f55\u548c\u9519\u8bef\u62a5\u544a\u529f\u80fd\u3002\u8981\u4f7f\u7528 supervisor \u8fd0\u884c\u6d88\u8d39\u8005\uff0c\u60a8\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a supervisor \u914d\u7f6e\u6587\u4ef6\uff1a [program:pheanstalk-consumer] command=\/usr\/local\/bin\/php \/path\/to\/consumer.php stdout_logfile=\/var\/log\/pheanstalk-consumer.log stderr_logfile=\/var\/log\/pheanstalk-consumer-error.log user=www-data linux systemd \u5982\u679c\u60a8\u4f7f\u7528\u7684\u662f linux \u7cfb\u7edf\uff0c\u53ef\u4ee5\u4f7f\u7528 systemd \u6765\u7ba1\u7406\u540e\u53f0\u8fdb\u7a0b\u3002\u8981\u4f7f\u7528 systemd \u8fd0\u884c\u6d88\u8d39\u8005\uff0c\u60a8\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a systemd \u5355\u5143\u6587\u4ef6\uff1a [unit] description=pheanstalk consumer after=network.target [service] type=simple execstart=\/usr\/local\/bin\/php \/path\/to\/consumer.php restart=on-failure [install] wantedby=multi-user.target [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-47804","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/47804","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=47804"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/47804\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=47804"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=47804"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=47804"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}