@@ -88,3 +88,98 @@ $pm2 kill
88
88
$pm2 l
89
89
NODE_PATH=' /test2' $pm2 start local_require.js -i 1
90
90
should ' should have loaded the right globalPaths' ' restart_time: 0' 1
91
+
92
+ #
93
+ # Ensuring that environment update works correctly when reloading with JSON config.
94
+ #
95
+ # Related issue:
96
+ # https://github.com/Unitech/pm2/issues/3192
97
+ #
98
+
99
+ # start with config
100
+ SH=shell_initial SH_PM=shell_initial $pm2 start update-env.config.js --env initial
101
+ > out-env.log
102
+
103
+ sleep 0.5
104
+ grep " SH=shell_initial PM=pm2_initial SH_PM=pm2_initial" out-env.log & > /dev/null
105
+ spec " should inject shell environment, then inject config environment on start with config"
106
+
107
+ # restart config without --update-env
108
+ $pm2 delete all
109
+ SH=shell_initial SH_PM=shell_initial $pm2 start update-env.config.js --env initial
110
+ SH=shell_updated SH_PM=shell_updated $pm2 restart update-env.config.js --env updated
111
+ > out-env.log
112
+
113
+ sleep 0.5
114
+ grep " SH=shell_updated PM=pm2_updated SH_PM=pm2_updated" out-env.log & > /dev/null
115
+ spec " should inject shell environment, then inject config environment on restart with config and without --update-env option"
116
+
117
+ # reload config without --update-env
118
+ $pm2 delete all
119
+ SH=shell_initial SH_PM=shell_initial $pm2 start update-env.config.js --env initial
120
+ SH=shell_updated SH_PM=shell_updated $pm2 reload update-env.config.js --env updated
121
+ > out-env.log
122
+
123
+ sleep 0.5
124
+ grep " SH=shell_updated PM=pm2_updated SH_PM=pm2_updated" out-env.log & > /dev/null
125
+ spec " should inject shell environment, then inject config environment on reload with config and without --update-env option"
126
+
127
+ # restart config with --update-env
128
+ $pm2 delete all
129
+ SH=shell_initial SH_PM=shell_initial $pm2 start update-env.config.js --env initial
130
+ SH=shell_updated SH_PM=shell_updated $pm2 restart update-env.config.js --env updated --update-env
131
+ > out-env.log
132
+
133
+ sleep 0.5
134
+ grep " SH=shell_updated PM=pm2_updated SH_PM=pm2_updated" out-env.log & > /dev/null
135
+ spec " should inject shell environment, then inject config environment on restart with config and with --update-env option"
136
+
137
+ # reload config with --update-env
138
+ $pm2 delete all
139
+ SH=shell_initial SH_PM=shell_initial $pm2 start update-env.config.js --env initial
140
+ SH=shell_updated SH_PM=shell_updated $pm2 reload update-env.config.js --env updated --update-env
141
+ > out-env.log
142
+
143
+ sleep 0.5
144
+ grep " SH=shell_updated PM=pm2_updated SH_PM=pm2_updated" out-env.log & > /dev/null
145
+ spec " should inject shell environment, then inject config environment on reload with config and with --update-env option"
146
+
147
+ # restart pid without --update-env
148
+ $pm2 delete all
149
+ SH=shell_initial SH_PM=shell_initial $pm2 start update-env.config.js --env initial
150
+ SH=shell_updated SH_PM=shell_updated $pm2 restart update_env_app
151
+ > out-env.log
152
+
153
+ sleep 0.5
154
+ grep " SH=shell_initial PM=pm2_initial SH_PM=pm2_initial" out-env.log & > /dev/null
155
+ spec " should keep environment on restart with pid and without --update-env option"
156
+
157
+ # reload pid without --update-env
158
+ $pm2 delete all
159
+ SH=shell_initial SH_PM=shell_initial $pm2 start update-env.config.js --env initial
160
+ SH=shell_updated SH_PM=shell_updated $pm2 reload update_env_app
161
+ > out-env.log
162
+
163
+ sleep 0.5
164
+ grep " SH=shell_initial PM=pm2_initial SH_PM=pm2_initial" out-env.log & > /dev/null
165
+ spec " should keep environment on reload with pid and without --update-env option"
166
+
167
+ # restart pid with --update-env
168
+ $pm2 delete all
169
+ SH=shell_initial SH_PM=shell_initial $pm2 start update-env.config.js --env initial
170
+ SH=shell_updated SH_PM=shell_updated $pm2 restart update_env_app --update-env
171
+ > out-env.log
172
+
173
+ sleep 0.5
174
+ grep " SH=shell_updated PM=pm2_initial SH_PM=shell_updated" out-env.log & > /dev/null
175
+ spec " should inject shell environment on restart with pid and with --update-env option"
176
+
177
+ # reload pid with --update-env
178
+ $pm2 delete all
179
+ SH=shell_initial SH_PM=shell_initial $pm2 start update-env.config.js --env initial
180
+ SH=shell_updated SH_PM=shell_updated $pm2 reload update_env_app --update-env
181
+ > out-env.log
182
+
183
+ sleep 0.5
184
+ grep " SH=shell_updated PM=pm2_initial SH_PM=shell_updated" out-env.log & > /dev/null
185
+ spec " should inject shell environment on reload with pid and with --update-env option"
0 commit comments