Pm2: Using PM2 to keep Laravel's artisan queue:listen alive.

Created on 17 Feb 2017  路  3Comments  路  Source: Unitech/pm2

I think I need some clarification on something.

when I run artisan queue:listen manually, it stays alive fine. but when I have PM2 run it, it keep restarting.

I have a config file that contains the following

{
    // Application #2
    "name": "artisan-queue-listen",
    "script": "artisan",
    "args": ["queue:listen", "--tries=1", "--sleep=1", "--timeout=120"],
    "exec_interpreter": "php",
    "exec_mode"  : "fork_mode",
    "watch": false,
    "merge_logs": true,
    "cwd": "/base/path/to/script/",
  }

and that's what I use to keep it alive.

Am I missing something?

Need More Data

Most helpful comment

Odd, this now works:

{
    // Application #2
    "name": "artisan-queue-listen",
    "script": "artisan",
    "args": ["queue:listen", "--tries=1", "--sleep=1", "--timeout=120"],
    "exec_interpreter": "php",
    "exec_mode"  : "fork_mode",
    "max_memory_restart" : "1G",
    "watch": false,
    "merge_logs": true,
    "cwd": "/base/path/to/script/",
  }

It must have been the max_memory_restart? does PM2 have a default value for this?

All 3 comments

Is there any logs ? (PM2 and the application) ?

Odd, this now works:

{
    // Application #2
    "name": "artisan-queue-listen",
    "script": "artisan",
    "args": ["queue:listen", "--tries=1", "--sleep=1", "--timeout=120"],
    "exec_interpreter": "php",
    "exec_mode"  : "fork_mode",
    "max_memory_restart" : "1G",
    "watch": false,
    "merge_logs": true,
    "cwd": "/base/path/to/script/",
  }

It must have been the max_memory_restart? does PM2 have a default value for this?

ok found the issue. Little known fact. watch:true watches everything under cwd so basically, even log file changes are considered file changes. will need to add exclusions specific to Laravel in this instance.

Was this page helpful?
0 / 5 - 0 ratings