最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - PM2 Managing PHP Script - Cluster mode - Stack Overflow

programmeradmin3浏览0评论

Currently i'm successfully managing some PHP deamons (single instance) with PM2, and, so far so good!

With PM2 and while managing Node.js/IO.js apps, i can launch them in cluster mode on PM2 with no stress! The same does not happen with the mentioned php deamons!

So, first of all, is it even possible to manage/launch clustered instances of a PHP script using PM2 (or is that PM2 feature only usable on Node.js/IO.js scripts)?

If so (possible to do), what special "tuneups" are required to cluster the PHP scripts with PM2!?

While trying to launch some pm2 start xxx.php -i 2 --name XXX, i get the following error @ the error log path:

SyntaxError: Unexpected token <
    at Module._pile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function._load (/usr/local/lib/node_modules/pm2/node_modules/pmx/lib/transaction.js:62:21)
    at /usr/local/lib/node_modules/pm2/lib/ProcessContainer.js:200:23
    at /usr/local/lib/node_modules/pm2/node_modules/async/lib/async.js:52:16
    at /usr/local/lib/node_modules/pm2/node_modules/async/lib/async.js:1209:30
    at WriteStream.<anonymous> (/usr/local/lib/node_modules/pm2/lib/Utility.js:126:13)
    at WriteStream.EventEmitter.emit (events.js:95:17)

... that makes me believe that it can't even parse the given PHP file!

Thanks in advance for any help on this!

Currently i'm successfully managing some PHP deamons (single instance) with PM2, and, so far so good!

With PM2 and while managing Node.js/IO.js apps, i can launch them in cluster mode on PM2 with no stress! The same does not happen with the mentioned php deamons!

So, first of all, is it even possible to manage/launch clustered instances of a PHP script using PM2 (or is that PM2 feature only usable on Node.js/IO.js scripts)?

If so (possible to do), what special "tuneups" are required to cluster the PHP scripts with PM2!?

While trying to launch some pm2 start xxx.php -i 2 --name XXX, i get the following error @ the error log path:

SyntaxError: Unexpected token <
    at Module._pile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function._load (/usr/local/lib/node_modules/pm2/node_modules/pmx/lib/transaction.js:62:21)
    at /usr/local/lib/node_modules/pm2/lib/ProcessContainer.js:200:23
    at /usr/local/lib/node_modules/pm2/node_modules/async/lib/async.js:52:16
    at /usr/local/lib/node_modules/pm2/node_modules/async/lib/async.js:1209:30
    at WriteStream.<anonymous> (/usr/local/lib/node_modules/pm2/lib/Utility.js:126:13)
    at WriteStream.EventEmitter.emit (events.js:95:17)

... that makes me believe that it can't even parse the given PHP file!

Thanks in advance for any help on this!

Share Improve this question asked Mar 14, 2016 at 15:33 undertugaundertuga 291 gold badge1 silver badge5 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 3

Short answer: you can't use cluster mode with php.

The pm2 cluster mode only works with javascript. Internally it's using the nodejs cluster module and requiring your script (code line). This also explains your error, pm2 tries to execute the php code with javascript (hence the SyntaxError).

When using fork mode, it's using your interpreter (here php) to launch the script. This is why you can also run python or ruby on top of nodejs!

发布评论

评论列表(0)

  1. 暂无评论