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

pm2.log and pm2.pid files location #438

Closed
adshpagin opened this issue Apr 29, 2014 · 11 comments
Closed

pm2.log and pm2.pid files location #438

adshpagin opened this issue Apr 29, 2014 · 11 comments

Comments

@adshpagin
Copy link

Hello! Thank you for the PM2 project, it's great!
I've got a question about pm2.log and pm2.pid files. As far as I know these files are always located in ~/.pm2/ directory and there is now way to change it via configuration.
Is it possible to add customization for the location of these files?
It would be great to have separate path settings for pm2.log and pm2.pid respectively.

For example:

/var/log/my_project/pm2.log
/var/run/my_project/pm2.pid

Thank you!

@soyuka
Copy link
Collaborator

soyuka commented Apr 29, 2014

https://github.com/Unitech/pm2#json-app-declaration

@soyuka soyuka closed this as completed Apr 29, 2014
@adshpagin
Copy link
Author

Yes, I've tried this, but these settings affect only child processes, their logs and pids. But the pm2.log and pm2.pid which belongs to main PM2 process are still present in ~/.pm2/ folder.
I've seen that their path is hardcoded in constants.js file:

PM2_LOG_FILE_PATH : p.join(p.resolve(process.env.HOME, '.pm2'), 'pm2.log'),
PM2_PID_FILE_PATH : p.join(p.resolve(process.env.HOME, '.pm2'), 'pm2.pid'),

Is my understanding right?

@soyuka
Copy link
Collaborator

soyuka commented Apr 29, 2014

process.env.HOME is the user home directory maybe you could try playing with that?

I know there are issues about pm2 user: #431, #260, #268 (even a PR #329) but could worth trying. Atm there is no way of changing the master pid/logs path.

Sorry that I misunderstood the question, re-opening.

@soyuka soyuka reopened this Apr 29, 2014
@adshpagin
Copy link
Author

Thanks for reopening an issue and for advice about $HOME env variable.
It's a good point about PM2 user. But even changing $HOME or PM2 user doesn't fully suite my issue.

I've found in constants.js that web interface port, for example, is done this way:

WEB_INTERFACE : parseInt(process.env.PM2_API_PORT) || 9615,

That means that if I want to set the web interface port I should simply define $PM2_API_PORT variable, otherwise the system takes the default 9615 value.

If it's possible to make the same with pm2.log and pm2.pid files:

PM2_LOG_FILE_PATH : p.join(process.env.PM2_LOG_DIR || p.resolve(process.env.HOME, '.pm2'), 'pm2.log') PM2_PID_FILE_PATH : p.join(process.env.PM2_PID_DIR || p.resolve(process.env.HOME, '.pm2'), 'pm2.pid')

In this case it's possible to set a separate paths for pm2.log and pm2.pid files using $PM2_LOG_DIR and $PM2_PID_DIR variables.

Does it make sense from your point of view?
Or there are some architectural concerns?

soyuka added a commit to soyuka/pm2 that referenced this issue Apr 29, 2014
@soyuka
Copy link
Collaborator

soyuka commented Apr 29, 2014

+1 it does make sense to me

@adshpagin
Copy link
Author

Thank you for the quick fix!

@stevenvachon
Copy link

The --error, --log and --output options seem to be completely ignored too. It's magically working now (?).

@steerben
Copy link

It seems that when transfering parts of the constants from constants.js to sample-conf.js the introduced functionality implemented in aa19782 has been removed. Could these two lines be added again to be able to set the pm2 log path via an env variable?

@zdychacek
Copy link

Will this functionality ever be restored again?

Thank you.

O.

@Unitech
Copy link
Owner

Unitech commented Jul 12, 2016

Feel free to send a PR on dev branch (https://github.com/Unitech/pm2/blob/development/paths.js) for this feature to land on PM2 2.0

Otherwise we will do it on PM2 > 2.0

@cdambo
Copy link

cdambo commented Jun 5, 2017

Thanks for this fix! when will it be released?

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

No branches or pull requests

7 participants