Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Json app declaration is not right #566

Closed
gywbd opened this issue Jul 12, 2014 · 13 comments
Closed

Json app declaration is not right #566

gywbd opened this issue Jul 12, 2014 · 13 comments

Comments

@gywbd
Copy link

gywbd commented Jul 12, 2014

I create a processes.json file following the document.

{
    "apps" : [
        {
            "name" : "test",
            "script" : "bin/www",
            "watch" : "true",
            "cwd" : "/Users/lscm/www/test",
            "env" : {
                "NODE_ENV" : "development"
            },
            "port" : 3000
        }
    ]
}

then I run "pm2 start processes.json" and get this error

path.js:313
        throw new TypeError('Arguments to path.resolve must be strings');
              ^
TypeError: Arguments to path.resolve must be strings
    at Object.exports.resolve (path.js:313:15)
    at Object.Common.resolveAppPaths (/usr/local/lib/node_modules/pm2/lib/Common.js:51:30)
    at resolvePaths (/usr/local/lib/node_modules/pm2/lib/CLI.js:890:20)
    at ex (/usr/local/lib/node_modules/pm2/lib/CLI.js:167:20)
    at Object.CLI.startFromJson (/usr/local/lib/node_modules/pm2/lib/CLI.js:205:5)
    at Command.<anonymous> (/usr/local/lib/node_modules/pm2/bin/pm2:126:11)
    at Command.<anonymous> (/usr/local/lib/node_modules/pm2/node_modules/commander/index.js:249:8)
    at Command.EventEmitter.emit (events.js:98:17)
    at Command.parseArgs (/usr/local/lib/node_modules/pm2/node_modules/commander/index.js:480:12)
    at Command.parse (/usr/local/lib/node_modules/pm2/node_modules/commander/index.js:372:21)

i checked the LINE 51 of "/usr/local/lib/node_modules/pm2/lib/Common.js", and console.log the app.script, it is undefined. then i change the processes.json and make it just and array, no "apps" field. the app.script gets the right value. but the I get another error

PM2 [ERROR] script not found : /Users/lscm/node/pm2/bin/www

Then I console.log the app variable in the Line 51 of Common.js. and I get this

{ name: 'cms-bbs',
  cwd: '/Users/lscm/www/cms-bbs',
  script: 'bin/www',
  watch: 'true',
  env: { NODE_ENV: 'development', pm_cwd: '/Users/lscm/node/pm2' },
  port: 3000,
  exec_interpreter: 'node',
  exec_mode: 'cluster_mode' }

So I think the "cwd" field does not work. and it just get the current directory where pm2 executed.

@soyuka
Copy link
Collaborator

soyuka commented Jul 12, 2014

PM2 [ERROR] script not found : /Users/lscm/node/pm2/bin/www

pm_cwd: '/Users/lscm/node/pm2'

Maybe pm_cwd is overriding cwd?

@Unitech
Copy link
Owner

Unitech commented Jul 12, 2014

Which version of PM2 ?

@gywbd
Copy link
Author

gywbd commented Jul 13, 2014

it is 0.8.6

i set the pm_cwd to /Users/lscm/node/pm2/bin/www. it still doesn't work. it looks like that pm2 will always set the pm_cwd to the current directory where pm2 executes

@soyuka
Copy link
Collaborator

soyuka commented Jul 13, 2014

Try updating:

npm update pm2 -g
pm2 updatePM2

@gywbd
Copy link
Author

gywbd commented Jul 13, 2014

it works. thanks!

@soyuka soyuka closed this as completed Jul 13, 2014
@ghost
Copy link

ghost commented Feb 26, 2015

I tried updating:
npm update pm2 -g
pm2 updatePM2

and now pm2 stopped working altogether!!

@jshkurti
Copy link
Contributor

@eligreg can you give us more details ?
What do you mean by stopped working ? Logs ?
Thanks

@ghost
Copy link

ghost commented Feb 26, 2015

Thanks for the quick response. I solved my issue by updating node. Phew.

@soyuka soyuka reopened this Feb 26, 2015
@Unitech Unitech closed this as completed Apr 15, 2015
@vijaybarnwal
Copy link

Hi,
I have the pm2 version 0.15.10. But still its showing me

[PM2][ERROR] script not found : /var/www/projects/mystore/app/index.js
script not found : /var/www/projects/mystore/app/index.js

I am worry about it. Can you please guide me whats the issue?

My json file config is :
{
"apps": [
{
"name" : "index",
"args" : ["-d", "1"],
"cwd" : "/var/www/projects/mystore/app",
"script" : "index.js ",
"instances" : 2,
"exec_interpreter": "node",
"error_file" : "err.log",
"out_file" : "out.log",
"merge_logs" : true,
"log_date_format" : "YYYY-MM-DD HH:mm Z",
"exec_mode" : "cluster",
"node_args" : ["--prof"],
"env" : {
"NODE_ENV" : "dev"
}
}
]
}

Thanks,
Vijay

@ravi
Copy link

ravi commented Nov 27, 2015

@vijaybarnwal not sure why you are posting this on an old issue. Try ./index.js and make sure node is in your PATH.

@vijaybarnwal
Copy link

Even that does not work. Node is there in my path

@soyuka
Copy link
Collaborator

soyuka commented Nov 27, 2015

script not found : /var/www/projects/mystore/app/index.js

Means there is no such file as /var/www/projects/mystore/app/index.js. Please double check for typo's.

@vijaybarnwal
Copy link

Hi there is index.js exists in this path. When I run pm2 start /var/www/projects/mystore/app/index.js its working.

But with json file its giving error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants