Skip to content

load configuration from /etc/default/pm2 #1850

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

Merged
merged 1 commit into from
Dec 21, 2015

Conversation

shaharmor
Copy link
Contributor

fixes #1844
fixes #1845

Unitech added a commit that referenced this pull request Dec 21, 2015
load configuration from /etc/default/pm2
@Unitech Unitech merged commit 38598c4 into Unitech:master Dec 21, 2015
@Unitech
Copy link
Owner

Unitech commented Dec 21, 2015

Looks great, thank you!

@Unitech
Copy link
Owner

Unitech commented Dec 21, 2015

I did some test, unfortunatelly environment variables loaded from /etc/default/pm2 are not passed to the pm2 command :/

because of the su - command: https://github.com/Unitech/pm2/blob/master/lib/scripts/pm2-init.sh#L55

I'm trying some stuff, if you have any idea it's welcome

@shaharmor
Copy link
Contributor Author

How did you test it? i am using something similar in production now.
Maybe its because i am using root user

@Unitech
Copy link
Owner

Unitech commented Dec 21, 2015

Replace:

su - $USER -s $shell -c "PATH=$PATH; PM2_HOME=$PM2_HOME $*"

By:

su - $USER -s $shell -c "env; PATH=$PATH; PM2_HOME=$PM2_HOME $*"

I've added PM2_KILL_TIMEOUT in /etc/default/pm2 and doing service pm2-init.sh restart, the variable is not present when doing the env command

@Unitech
Copy link
Owner

Unitech commented Dec 21, 2015

I found the solution, when importing variables we must do set -a then when we finished we do set -a

On the su command we just need to pass the -m option to preserve environment variable

But now the problem is that if someone use the /etc/default/pm2 file for configuration variables, PM2 is not aware itself of this file, so I will continue to think about this way of configuring PM2

@shaharmor
Copy link
Contributor Author

I'm not sure this is supposed to be used to set environment variables, but instead just bash variables

@shaharmor
Copy link
Contributor Author

Its not supposed to replace PM2 environment variables (Which for themselves should move to the app json), but just startup variables like ulimit

@Unitech
Copy link
Owner

Unitech commented Dec 21, 2015

Yes I was thinking that it could be a good way to configure some internals PM2 variables but yes you are right, let's keep the /etc/default/pm2 for startup variables

@shaharmor shaharmor deleted the feature/init-script branch December 21, 2015 19:12
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.

add ulimit -n override in pm2-init.sh PM2-init.sh - load defaults from /etc/default/pm2
2 participants