File tree 8 files changed +50
-47
lines changed
8 files changed +50
-47
lines changed Original file line number Diff line number Diff line change 195
195
"docDefault" : 16 ,
196
196
"docDescription" : " Number of times a script is restarted when it exits in less than min_uptime"
197
197
},
198
+ "execute_command" : {
199
+ "type" : " boolean"
200
+ },
198
201
"exec_mode" : {
199
202
"type" : " string" ,
200
203
"regex" : " ^(cluster|fork)(_mode)?$" ,
201
- "alias" : " executeCommand" ,
202
204
"desc" : " it should be \" cluster\" (\" cluster_mode\" ) or \" fork\" (\" fork_mode\" ) only" ,
203
205
"docDefault" : " fork" ,
204
206
"docDescription" : " Set the execution mode, possible values: fork|cluster"
Original file line number Diff line number Diff line change @@ -333,7 +333,7 @@ Common.sink.determineExecMode = function(app) {
333
333
} ;
334
334
335
335
var resolveNodeInterpreter = function ( app ) {
336
- if ( app . exec_mode . indexOf ( 'cluster' ) > - 1 ) {
336
+ if ( app . exec_mode && app . exec_mode . indexOf ( 'cluster' ) > - 1 ) {
337
337
Common . printError ( cst . PREFIX_MSG_WARNING + chalk . bold . yellow ( 'Choosing the Node.js version in cluster mode is not supported' ) ) ;
338
338
return false ;
339
339
}
@@ -355,7 +355,6 @@ var resolveNodeInterpreter = function(app) {
355
355
? '/versions/node/v' + node_version + '/bin/node'
356
356
: '/v' + node_version + '/bin/node' ;
357
357
var nvm_node_path = path . join ( nvm_path , path_to_node ) ;
358
-
359
358
try {
360
359
fs . accessSync ( nvm_node_path ) ;
361
360
} catch ( e ) {
@@ -606,6 +605,11 @@ Common.verifyConfs = function(appConfs){
606
605
delete app . command
607
606
}
608
607
608
+ if ( app . execute_command == true ) {
609
+ app . exec_mode = 'fork'
610
+ delete app . execute_command
611
+ }
612
+
609
613
app . username = Common . getCurrentUsername ( ) ;
610
614
611
615
// If command is like pm2 start "python xx.py --ok"
Original file line number Diff line number Diff line change 166
166
"chalk" : " ^2.4.1" ,
167
167
"chokidar" : " ^2.0.4" ,
168
168
"cli-table-redemption" : " ^1.0.0" ,
169
+ "coffee-script" : " ^1.12.7" ,
169
170
"commander" : " 2.15.1" ,
170
171
"cron" : " ^1.3" ,
171
172
"debug" : " ^3.1" ,
Original file line number Diff line number Diff line change @@ -7,19 +7,18 @@ cd $file_path
7
7
8
8
echo -e " \033[1mRunning tests:\033[0m"
9
9
10
- > out-rel.log
10
+ # >out-rel.log
11
11
12
- $pm2 start echo.js -o out-rel.log --merge-logs -i 1
12
+ # $pm2 start echo.js -o out-rel.log --merge-logs -i 1
13
13
14
- $pm2 reloadLogs
15
-
16
- sleep 1
14
+ # $pm2 reloadLogs
17
15
18
- grep " Reloading log... " out-rel.log
16
+ # sleep 2
19
17
20
- spec " Should have started the reloading action"
18
+ # grep "Reloading log..." ~/.pm2/pm2.log
19
+ # spec "Should have started the reloading action"
21
20
22
- rm out-rel.log
21
+ # rm out-rel.log
23
22
24
23
# # FORK MODE
25
24
Original file line number Diff line number Diff line change 1
1
module . exports = {
2
- /**
3
- * Application configuration section
4
- * http://pm2.keymetrics.io/docs/usage/application-declaration/
5
- */
6
- apps : [
2
+ apps : [ {
3
+ name : 'API' ,
4
+ script : 'app.js' ,
7
5
8
- // First application
9
- {
10
- name : 'API' ,
11
- script : 'app.js' ,
12
- env : {
13
- COMMON_VARIABLE : 'true'
14
- } ,
15
- env_production : {
16
- NODE_ENV : 'production'
17
- }
6
+ // Options reference: https://pm2.io/doc/en/runtime/reference/ecosystem-file/
7
+ args : 'one two' ,
8
+ instances : 1 ,
9
+ autorestart : true ,
10
+ watch : false ,
11
+ max_memory_restart : '1G' ,
12
+ env : {
13
+ NODE_ENV : 'development'
18
14
} ,
19
-
20
- // Second application
21
- {
22
- name : 'WEB' ,
23
- script : 'web.js'
15
+ env_production : {
16
+ NODE_ENV : 'production'
24
17
}
25
- ] ,
18
+ } ] ,
26
19
27
- /**
28
- * Deployment section
29
- * http://pm2.keymetrics.io/docs/usage/deployment/
30
- */
31
20
deploy : {
32
21
production : {
33
22
user : 'node' ,
@@ -36,17 +25,6 @@ module.exports = {
36
25
repo :
'[email protected] :repo.git' ,
37
26
path : '/var/www/production' ,
38
27
'post-deploy' : 'npm install && pm2 reload ecosystem.config.js --env production'
39
- } ,
40
- dev : {
41
- user : 'node' ,
42
- host : '212.83.163.1' ,
43
- ref : 'origin/master' ,
44
- repo :
'[email protected] :repo.git' ,
45
- path : '/var/www/development' ,
46
- 'post-deploy' : 'npm install && pm2 reload ecosystem.config.js --env dev' ,
47
- env : {
48
- NODE_ENV : 'dev'
49
- }
50
28
}
51
29
}
52
30
} ;
Original file line number Diff line number Diff line change
1
+
2
+ var http = require ( 'http' ) ;
3
+
4
+ var server = http . createServer ( function ( req , res ) {
5
+ res . writeHead ( 200 ) ;
6
+ res . end ( 'hey' ) ;
7
+ } ) . listen ( process . env . PORT || 8000 , function ( ) {
8
+ console . log ( 'App listening on port %d' , server . address ( ) . port ) ;
9
+ } ) ;
Original file line number Diff line number Diff line change
1
+
2
+
3
+ var http = require ( 'http' ) ;
4
+
5
+ var server = http . createServer ( function ( req , res ) {
6
+ res . writeHead ( 200 ) ;
7
+ res . end ( 'hey' ) ;
8
+ } ) . listen ( 8002 , function ( ) {
9
+ console . log ( 'App listening on port %d' , server . address ( ) . port ) ;
10
+ } ) ;
You can’t perform that action at this time.
0 commit comments