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

Use current directory for .pm2 when no $HOME defined #830

Closed
wants to merge 1 commit into from

Conversation

gierschv
Copy link

$ pm2 -v
0.12.1
$ unset HOME
$ pm2 -v    

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.<anonymous> (/home/vgiersch/bin/node-v0.10.26-linux-x64/lib/node_modules/pm2/constants.js:15:21)
    at Module._compile (module.js:456:26)
    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 Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/home/vgiersch/bin/node-v0.10.26-linux-x64/lib/node_modules/pm2/lib/Satan.js:18:14)
    at Module._compile (module.js:456:26)

Signed-off-by: Vincent Giersch <vincent.giersch@ovh.net>
@soyuka
Copy link
Collaborator

soyuka commented Nov 21, 2014

Nice idea, and could be a fix for #789

@gierschv
Copy link
Author

@soyuka For #789, it depends what is the cwd. Maybe we should use project directory instead of current working directory when no $HOME, or just throw a clean error message. Anyway, a better option is to set $PM2_HOME.

@Tjatse
Copy link
Collaborator

Tjatse commented Nov 22, 2014

To be honest, I don't think this is a good idea, path.resolve('') returns the CWD, that means all the PM2 confs (like logs, pids, pm2*) will be putted in to CWD, thats inadvisable. e.g.:
BASH

$ cd /var/www/my-codes
$ unset HOME
$ unset PM2_HOME
$ pm2 start test.js

You'll find there is such a cram in the /var/www/my-codes directory.
DIRS

/var/www/my-codes/.pm2/logs
/var/www/my-codes/.pm2/pids
/var/www/my-codes/.pm2/pm2.log
...

How about we have another project under /var/www/my-codes2, after we ran the BASH
Now the DIRS

/var/www/my-codes2/.pm2/logs
/var/www/my-codes2/.pm2/pids
/var/www/my-codes2/.pm2/pm2.log
...

Yap, the logs do not tangle up anymore.

Taking ~/.pm2 for the ROOT-DIR of PM2 is a good idea but not best, 'Cause we always facing root/nobody user problems (or su/sudo to start PM2 then downgrade permission to nobody), actually I think /opt/pm2 should be ROOT-DIR by default:

/opt is for "the installation of add-on application software packages", it is a directory where to install unbundled packages, each in its own subdirectory.

Unitech pushed a commit that referenced this pull request Jan 28, 2015
@Unitech Unitech closed this Jan 28, 2015
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

Successfully merging this pull request may close these issues.

None yet

4 participants