-
Notifications
You must be signed in to change notification settings - Fork 948
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
Preserve environment when restarting #116
Comments
@sbrekken How exactly are you starting your server? If you are running $ NODE_ENV=production node myapp.js Then the process is not managed by forever. |
I corrected the obvious(?) typo. |
Ahhh ... I see now. I fixed this: $ NODE_ENV=production forever start examples/env-server.js
info: Running action: start
info: Forever processing file: examples/env-server.js
$ curl http://localhost:8080/
{"NODE_ENV":"production","TERM_PROGRAM":"Apple_Terminal","TERM":"xterm-color","SHELL":"/bin/bash","TMPDIR":"/var/folders/fH/fHuTLtiHGgOZ9Cronn9zME+++TI/-Tmp-/","Apple_PubSub_Socket_Render":"/tmp/launch-bAspNE/Render","TERM_PROGRAM_VERSION":"273.1","OLDPWD":"/Users/Charlie/GitHub","USER":"Charlie","COMMAND_MODE":"unix2003","SSH_AUTH_SOCK":"/tmp/launch-AlvGeu/Listeners","__CF_USER_TEXT_ENCODING":"0x1F5:0:0","PATH":"/usr/src/ImageMagick-6.6.4/bin:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin","PWD":"/Users/Charlie/GitHub/forever","LANG":"en_US.UTF-8","MAGICK_HOME":"/usr/src/ImageMagick-6.6.4","SHLVL":"1","HOME":"/Users/Charlie","DYLD_LIBRARY_PATH":"/usr/src/ImageMagick-6.6.4/lib","LOGNAME":"Charlie","PKG_CONFIG_PATH":"/Users/Charlie/GitHub/kod/deps/libcss/libparserutils/:/Users/Charlie/GitHub/kod/deps/libcss/libwapcaplet/:","DISPLAY":"/tmp/launch-eaFQnj/org.x:0","_":"/usr/local/bin/forever"}
$ forever restart 0
info: Running action: restart
info: Forever restarted process(es):
data: uid command script forever pid logfile uptime
data: [0] 8f6x node examples/env-server.js 24333 24334 /Users/Charlie/.forever/8f6x.log 0:0:0:19.334
$ forever list
info: Running action: list
info: Forever processes running
data: uid command script forever pid logfile uptime
data: [0] nBdW node examples/env-server.js 24438 24439 /Users/Charlie/.forever/8f6x.log 0:0:0:1.707
$ curl http://localhost:8080/
{"TERM_PROGRAM":"Apple_Terminal","SHELL":"/bin/bash","TERM":"xterm-color","TMPDIR":"/var/folders/fH/fHuTLtiHGgOZ9Cronn9zME+++TI/-Tmp-/","Apple_PubSub_Socket_Render":"/tmp/launch-bAspNE/Render","TERM_PROGRAM_VERSION":"273.1","USER":"Charlie","COMMAND_MODE":"unix2003","SSH_AUTH_SOCK":"/tmp/launch-AlvGeu/Listeners","__CF_USER_TEXT_ENCODING":"0x1F5:0:0","PATH":"/usr/src/ImageMagick-6.6.4/bin:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin","_":"/usr/local/bin/forever","PWD":"/Users/Charlie/GitHub/forever","LANG":"en_US.UTF-8","NODE_ENV":"production","MAGICK_HOME":"/usr/src/ImageMagick-6.6.4","HOME":"/Users/Charlie","SHLVL":"2","DYLD_LIBRARY_PATH":"/usr/src/ImageMagick-6.6.4/lib","LOGNAME":"Charlie","PKG_CONFIG_PATH":"/Users/Charlie/GitHub/kod/deps/libcss/libparserutils/:/Users/Charlie/GitHub/kod/deps/libcss/libwapcaplet/:","DISPLAY":"/tmp/launch-eaFQnj/org.x:0"} Environment variable is now still present |
Published in npm as |
Is there any way that this fix can be made compatible with reloading new versions of other environment variables? That is, if you pass in something (like |
👍 to @Californian Or simply allow refreshing env vars on |
+1 to @Californian |
I've just encountered this in production where I'd first start a server with
NODE_ENV=production forever start myapp.js
and later attempt to restart it usingforever restart myapp.js
which would result in my restarted server being in development mode.Perhaps it would be best if the environment each process was started with gets restored when restarting?
The text was updated successfully, but these errors were encountered: