pm2 icon indicating copy to clipboard operation
pm2 copied to clipboard

PM2 deploy - Invalid or unexpected token - macOS Sierra

Open sudheeshcm opened this issue 9 years ago • 6 comments

Hi, I've been trying to deploy code from git to various machines including my localhost using the below configurations. PM2 deploy works fine in other systems that I've tried. But fails with a message Invalid or unexpected token in my MacOS sierra installed MacBook pro. Please find the JSON configurations I've been working with below.

{
  "apps" : [{
    "name": "fr-catalog-admin-v2-server",
    "script": "./server.js",
    "env_development": {
      "NODE_ENV": "development"
    },
    "env_production": {
      "NODE_ENV": "production"
    },
    "env_staging": {
      "NODE_ENV": "staging"
    },
    "cwd": "/srv/catalog/fr-catalog-admin-v2/current/server",
    "log_date_format": "YYYY-MM-DD HH:mm:ss.SSS Z",
    "watch": false
  },
  {
    "name": "fr-catalog-admin-v2-client",
    "script": "./client.js",
    "env_development": {
      "NODE_ENV": "development"
    },
    "env_production": {
      "NODE_ENV": "production"
    },
    "env_staging": {
      "NODE_ENV": "staging"
    },
    "cwd": "/srv/catalog/fr-catalog-admin-v2/current/client",
    "log_date_format": "YYYY-MM-DD HH:mm:ss.SSS Z",
    "watch": false
  }],
  "deploy": {
    "development": {
      "env": {
        "NODE_ENV": "development",
      },
      "ref": "origin/cat147-nodeDeploymentUpdate",
      "host": "localhost",
      "repo": "*****",
      "path": "/srv/catalog/fr-catalog-admin-v2",
      "pre-deploy": "git fetch --all && git checkout cat147-nodeDeploymentUpdate",
      "post-deploy": "cd client && npm install && gulp moveStaticFiles && cd ../server && npm install && pm2 startOrRestart ./config/pm2/pm2.json --env development",
      "user": "qbuser"
    },
    ...
  }
}

Expected behavior

To deploy code from git, and setup as per the configuration.

Actual behaviour

apples-MacBook-Pro:~ Sudheesh$ pm2 deploy pm2.json development setup Invalid or unexpected token

Steps to reproduce

pm2 deploy pm2.json development setup

Software versions used

OS         : MacOS Sierra 10.12.2
node.js    : 6.9.2
PM2        : 2.3.0

PM2 Log output

apples-MacBook-Pro:~ Sudheesh$ tail -f  ~/.pm2/pm2.log
2017-01-26 10:34:14: Current arch         : x64
2017-01-26 10:34:14: PM2 home             : /Users/sudheesh/.pm2
2017-01-26 10:34:14: PM2 PID file         : /Users/sudheesh/.pm2/pm2.pid
2017-01-26 10:34:14: RPC socket file      : /Users/sudheesh/.pm2/rpc.sock
2017-01-26 10:34:14: BUS socket file      : /Users/sudheesh/.pm2/pub.sock
2017-01-26 10:34:14: Application log path : /Users/sudheesh/.pm2/logs
2017-01-26 10:34:14: Process dump file    : /Users/sudheesh/.pm2/dump.pm2
2017-01-26 10:34:14: Concurrent actions   : 2
2017-01-26 10:34:14: SIGTERM timeout      : 1600
2017-01-26 10:34:14: ===============================================================================

Couldn't find any other issues or suspicious logs. I've verified the git ssh keys manually by cloning the repo correctly.

Thanks, Sudheesh CM

sudheeshcm avatar Jan 26 '17 08:01 sudheeshcm

Could you try running DEBUG=* pm2 deploy pm2.json development setup log and paste the logs here ? I started rewriting pm2 deploy, currently its in-dev but i guess you could try see if its working for your use case (repo here)

vmarchaud avatar Jan 26 '17 10:01 vmarchaud

@vmarchaud

apples-MacBook-Pro:~ Sudheesh$ DEBUG=* pm2 deploy pm2.json development setup
  pm2:paths pm2 home resolved to /Users/sudheesh/.pm2 /Users/sudheesh +0ms
  pm2:conf Using 2 parallelism (CONCURRENT_ACTIONS) +8ms
  pm2:client Using RPC file /Users/sudheesh/.pm2/rpc.sock +177ms
  pm2:client Using PUB file /Users/sudheesh/.pm2/pub.sock +0ms
  pm2:interface:daemon Getting interaction info +0ms
  pm2:interface:daemon [PING INTERACTOR] Trying to connect to Interactor daemon +1ms
  axon:sock connect attempt null:/Users/sudheesh/.pm2/interactor.sock +0ms
  pm2:client [PING PM2] Trying to connect to server +5ms
  axon:sock connect attempt null:/Users/sudheesh/.pm2/rpc.sock +3ms
  axon:sock error ENOENT +4ms
  axon:sock ignored ENOENT +0ms
  axon:sock connect +1ms
  axon:sock add socket 0 +0ms
  axon:queue flush 0 messages +1ms
  axon:sock closing +0ms
  axon:sock closing 1 connections +0ms
  pm2:client Daemon alive +7ms
  axon:sock remove socket 0 +2ms
  pm2:client Launching RPC client on socket file /Users/sudheesh/.pm2/rpc.sock +1ms
  axon:sock connect attempt null:/Users/sudheesh/.pm2/rpc.sock +0ms
  axon:sock connect +1ms
  axon:sock add socket 0 +0ms
  axon:queue flush 0 messages +0ms
  pm2:client RPC Connected to Daemon +2ms
  pm2:cli Now connected to daemon +6ms
  pm2:client Calling daemon method pm2:getVersion on rpc socket:/Users/sudheesh/.pm2/rpc.sock +1ms
Invalid or unexpected token
  axon:sock closing +33ms
  axon:sock closing 1 connections +0ms
  axon:sock remove socket 0 +0ms
  pm2:client PM2 RPC cleanly closed +26ms
  pm2:cli This command took 0.043s to execute +0ms
apples-MacBook-Pro:~ Sudheesh$ 

I'll try with you new code. Will update you if there's any progress.

sudheeshcm avatar Jan 27 '17 05:01 sudheeshcm

Hey Guys, Was this issue fixed ? I'm getting the exact same problem.

pchambeth avatar May 31 '17 11:05 pchambeth

I have the same issue, after upgrade to node 8.9.1

any news of fix this issue?

sas05 avatar Nov 16 '17 08:11 sas05

ok, I'm dumb. there was a syntax error. @sudheeshcm could you share you deploy script? or check your deploy script, probably there was an error.

sas05 avatar Nov 16 '17 08:11 sas05

This is a syntax problem, some comma in wrong place, something like this.

beduka-code avatar Jan 21 '21 18:01 beduka-code