@@ -49,67 +49,23 @@ describe('test/stop.test.js', () => {
4949 yield utils . cleanup ( fixturePath ) ;
5050 } ) ;
5151
52- describe ( 'full path' , ( ) => {
53- it ( 'should stop' , function * ( ) {
54- killer = coffee . fork ( eggBin , [ 'stop' , fixturePath ] ) ;
55- killer . debug ( ) ;
56- killer . expect ( 'code' , 0 ) ;
57-
58- // yield killer.end();
59- yield sleep ( waitTime ) ;
60-
61- // make sure is kill not auto exist
62- assert ( ! app . stdout . includes ( 'exist by env' ) ) ;
63-
64- assert ( app . stdout . includes ( '[master] receive signal SIGTERM, closing' ) ) ;
65- assert ( app . stdout . includes ( '[master] exit with code:0' ) ) ;
66- assert ( app . stdout . includes ( '[app_worker] exit with code:0' ) ) ;
67- // assert(app.stdout.includes('[agent_worker] exit with code:0'));
68- assert ( killer . stdout . includes ( `[egg-scripts] stopping egg application at ${ fixturePath } ` ) ) ;
69- assert ( killer . stdout . match ( / g o t m a s t e r p i d \[ " \d + \" \] / i) ) ;
70- } ) ;
71- } ) ;
52+ it ( 'should stop' , function * ( ) {
53+ killer = coffee . fork ( eggBin , [ 'stop' , fixturePath ] ) ;
54+ killer . debug ( ) ;
55+ killer . expect ( 'code' , 0 ) ;
7256
73- describe ( 'relative path' , ( ) => {
74- it ( 'should stop' , function * ( ) {
75- killer = coffee . fork ( eggBin , [ 'stop' , path . relative ( process . cwd ( ) , fixturePath ) ] ) ;
76- killer . debug ( ) ;
77- killer . expect ( 'code' , 0 ) ;
78-
79- // yield killer.end();
80- yield sleep ( waitTime ) ;
81-
82- // make sure is kill not auto exist
83- assert ( ! app . stdout . includes ( 'exist by env' ) ) ;
84-
85- assert ( app . stdout . includes ( '[master] receive signal SIGTERM, closing' ) ) ;
86- assert ( app . stdout . includes ( '[master] exit with code:0' ) ) ;
87- assert ( app . stdout . includes ( '[app_worker] exit with code:0' ) ) ;
88- // assert(app.stdout.includes('[agent_worker] exit with code:0'));
89- assert ( killer . stdout . includes ( `[egg-scripts] stopping egg application at ${ fixturePath } ` ) ) ;
90- assert ( killer . stdout . match ( / g o t m a s t e r p i d \[ " \d + \" \] / i) ) ;
91- } ) ;
92- } ) ;
57+ // yield killer.end();
58+ yield sleep ( waitTime ) ;
59+
60+ // make sure is kill not auto exist
61+ assert ( ! app . stdout . includes ( 'exist by env' ) ) ;
9362
94- describe ( 'without baseDir' , ( ) => {
95- it ( 'should stop' , function * ( ) {
96- killer = coffee . fork ( eggBin , [ 'stop' ] , { cwd : fixturePath } ) ;
97- killer . debug ( ) ;
98- killer . expect ( 'code' , 0 ) ;
99-
100- // yield killer.end();
101- yield sleep ( waitTime ) ;
102-
103- // make sure is kill not auto exist
104- assert ( ! app . stdout . includes ( 'exist by env' ) ) ;
105-
106- assert ( app . stdout . includes ( '[master] receive signal SIGTERM, closing' ) ) ;
107- assert ( app . stdout . includes ( '[master] exit with code:0' ) ) ;
108- assert ( app . stdout . includes ( '[app_worker] exit with code:0' ) ) ;
109- // assert(app.stdout.includes('[agent_worker] exit with code:0'));
110- assert ( killer . stdout . includes ( `[egg-scripts] stopping egg application at ${ fixturePath } ` ) ) ;
111- assert ( killer . stdout . match ( / g o t m a s t e r p i d \[ " \d + \" \] / i) ) ;
112- } ) ;
63+ assert ( app . stdout . includes ( '[master] receive signal SIGTERM, closing' ) ) ;
64+ assert ( app . stdout . includes ( '[master] exit with code:0' ) ) ;
65+ assert ( app . stdout . includes ( '[app_worker] exit with code:0' ) ) ;
66+ // assert(app.stdout.includes('[agent_worker] exit with code:0'));
67+ assert ( killer . stdout . includes ( '[egg-scripts] stopping egg application' ) ) ;
68+ assert ( killer . stdout . match ( / g o t m a s t e r p i d \[ " \d + \" \] / i) ) ;
11369 } ) ;
11470 } ) ;
11571
@@ -132,7 +88,7 @@ describe('test/stop.test.js', () => {
13288 it ( 'should stop' , function * ( ) {
13389 yield coffee . fork ( eggBin , [ 'stop' , fixturePath ] )
13490 . debug ( )
135- . expect ( 'stdout' , new RegExp ( `\\ [egg-scripts] stopping egg application at ${ fixturePath } ` ) )
91+ . expect ( 'stdout' , / \ [e g g - s c r i p t s ] s t o p p i n g e g g a p p l i c a t i o n / )
13692 . expect ( 'stdout' , / g o t m a s t e r p i d \[ " \d + \" \] / i)
13793 . expect ( 'code' , 0 )
13894 . end ( ) ;
@@ -159,10 +115,116 @@ describe('test/stop.test.js', () => {
159115 yield utils . cleanup ( fixturePath ) ;
160116 yield coffee . fork ( eggBin , [ 'stop' , fixturePath ] )
161117 . debug ( )
162- . expect ( 'stdout' , new RegExp ( `\\[egg-scripts] stopping egg application at ${ fixturePath } ` ) )
118+ . expect ( 'stdout' , / \[ e g g - s c r i p t s ] s t o p p i n g e g g a p p l i c a t i o n / )
119+ . expect ( 'stderr' , / c a n ' t d e t e c t a n y r u n n i n g e g g p r o c e s s / )
120+ . expect ( 'code' , 0 )
121+ . end ( ) ;
122+ } ) ;
123+ } ) ;
124+
125+ describe ( 'stop --title' , ( ) => {
126+ let app ;
127+ let killer ;
128+
129+ beforeEach ( function * ( ) {
130+ yield utils . cleanup ( fixturePath ) ;
131+ app = coffee . fork ( eggBin , [ 'start' , '--workers=2' , '--title=example' , fixturePath ] ) ;
132+ // app.debug();
133+ app . expect ( 'code' , 0 ) ;
134+ yield sleep ( waitTime ) ;
135+
136+ assert ( app . stderr === '' ) ;
137+ assert ( app . stdout . match ( / c u s t o m - f r a m e w o r k s t a r t e d o n h t t p : \/ \/ 1 2 7 \. 0 \. 0 \. 1 : 7 0 0 1 / ) ) ;
138+ const result = yield httpclient . request ( 'http://127.0.0.1:7001' ) ;
139+ assert ( result . data . toString ( ) === 'hi, egg' ) ;
140+ } ) ;
141+
142+ afterEach ( function * ( ) {
143+ app . proc . kill ( 'SIGTERM' ) ;
144+ yield utils . cleanup ( fixturePath ) ;
145+ } ) ;
146+
147+ it ( 'should stop' , function * ( ) {
148+ yield coffee . fork ( eggBin , [ 'stop' , '--title=random' , fixturePath ] )
149+ . debug ( )
150+ . expect ( 'stdout' , / \[ e g g - s c r i p t s ] s t o p p i n g e g g a p p l i c a t i o n w i t h - - t i t l e = r a n d o m / )
163151 . expect ( 'stderr' , / c a n ' t d e t e c t a n y r u n n i n g e g g p r o c e s s / )
164152 . expect ( 'code' , 0 )
165153 . end ( ) ;
154+
155+ killer = coffee . fork ( eggBin , [ 'stop' , '--title=example' ] , { cwd : fixturePath } ) ;
156+ killer . debug ( ) ;
157+ killer . expect ( 'code' , 0 ) ;
158+
159+ // yield killer.end();
160+ yield sleep ( waitTime ) ;
161+
162+ // make sure is kill not auto exist
163+ assert ( ! app . stdout . includes ( 'exist by env' ) ) ;
164+
165+ assert ( app . stdout . includes ( '[master] receive signal SIGTERM, closing' ) ) ;
166+ assert ( app . stdout . includes ( '[master] exit with code:0' ) ) ;
167+ assert ( app . stdout . includes ( '[app_worker] exit with code:0' ) ) ;
168+ // assert(app.stdout.includes('[agent_worker] exit with code:0'));
169+ assert ( killer . stdout . includes ( '[egg-scripts] stopping egg application with --title=example' ) ) ;
170+ assert ( killer . stdout . match ( / g o t m a s t e r p i d \[ " \d + \" \] / i) ) ;
171+ } ) ;
172+ } ) ;
173+
174+ describe ( 'stop all' , ( ) => {
175+ let app ;
176+ let app2 ;
177+ let killer ;
178+
179+ beforeEach ( function * ( ) {
180+ yield utils . cleanup ( fixturePath ) ;
181+ app = coffee . fork ( eggBin , [ 'start' , '--workers=2' , '--title=example' , fixturePath ] ) ;
182+ // app.debug();
183+ app . expect ( 'code' , 0 ) ;
184+
185+ app2 = coffee . fork ( eggBin , [ 'start' , '--workers=2' , '--title=test' , '--port=7002' , fixturePath ] ) ;
186+ app2 . expect ( 'code' , 0 ) ;
187+
188+ yield sleep ( waitTime ) ;
189+
190+ assert ( app . stderr === '' ) ;
191+ assert ( app . stdout . match ( / c u s t o m - f r a m e w o r k s t a r t e d o n h t t p : \/ \/ 1 2 7 \. 0 \. 0 \. 1 : 7 0 0 1 / ) ) ;
192+ const result = yield httpclient . request ( 'http://127.0.0.1:7001' ) ;
193+ assert ( result . data . toString ( ) === 'hi, egg' ) ;
194+
195+ assert ( app2 . stderr === '' ) ;
196+ assert ( app2 . stdout . match ( / c u s t o m - f r a m e w o r k s t a r t e d o n h t t p : \/ \/ 1 2 7 \. 0 \. 0 \. 1 : 7 0 0 2 / ) ) ;
197+ const result2 = yield httpclient . request ( 'http://127.0.0.1:7002' ) ;
198+ assert ( result2 . data . toString ( ) === 'hi, egg' ) ;
199+ } ) ;
200+
201+ afterEach ( function * ( ) {
202+ app . proc . kill ( 'SIGTERM' ) ;
203+ app2 . proc . kill ( 'SIGTERM' ) ;
204+ yield utils . cleanup ( fixturePath ) ;
205+ } ) ;
206+
207+ it ( 'should stop' , function * ( ) {
208+ killer = coffee . fork ( eggBin , [ 'stop' ] , { cwd : fixturePath } ) ;
209+ killer . debug ( ) ;
210+ killer . expect ( 'code' , 0 ) ;
211+
212+ // yield killer.end();
213+ yield sleep ( waitTime ) ;
214+
215+ // make sure is kill not auto exist
216+ assert ( ! app . stdout . includes ( 'exist by env' ) ) ;
217+ assert ( app . stdout . includes ( '[master] receive signal SIGTERM, closing' ) ) ;
218+ assert ( app . stdout . includes ( '[master] exit with code:0' ) ) ;
219+ assert ( app . stdout . includes ( '[app_worker] exit with code:0' ) ) ;
220+ // assert(app.stdout.includes('[agent_worker] exit with code:0'));
221+ assert ( killer . stdout . includes ( '[egg-scripts] stopping egg application' ) ) ;
222+ assert ( killer . stdout . match ( / g o t m a s t e r p i d \[ " \d + \" , " \d + \" \] / i) ) ;
223+
224+ assert ( ! app2 . stdout . includes ( 'exist by env' ) ) ;
225+ assert ( app2 . stdout . includes ( '[master] receive signal SIGTERM, closing' ) ) ;
226+ assert ( app2 . stdout . includes ( '[master] exit with code:0' ) ) ;
227+ assert ( app2 . stdout . includes ( '[app_worker] exit with code:0' ) ) ;
166228 } ) ;
167229 } ) ;
168230} ) ;
0 commit comments