File tree Expand file tree Collapse file tree 4 files changed +57
-0
lines changed Expand file tree Collapse file tree 4 files changed +57
-0
lines changed Original file line number Diff line number Diff line change
1
+ "use strict" ;
2
+ var path = require ( 'path' )
3
+ , log4js = require ( '../lib/log4js' ) ;
4
+
5
+ log4js . configure (
6
+ // config reloading only works with file-based config (obvs)
7<
8000
/code>
+ path . join ( __dirname , '../test/tape/test-config.json' ) ,
8
+ { reloadSecs : 10 }
9
+ ) ;
10
+
11
+ log4js . getLogger ( 'testing' ) . info ( "Just testing" ) ;
12
+ log4js . shutdown ( function ( ) {
13
+ //callback gets you notified when log4js has finished shutting down.
14
+ } ) ;
Original file line number Diff line number Diff line change @@ -452,6 +452,11 @@ function shutdown(cb) {
452
452
// not being able to be drained because of run-away log writes.
453
453
loggerModule . disableAllLogWrites ( ) ;
454
454
455
+ //turn off config reloading
456
+ if ( configState . timerId ) {
457
+ clearInterval ( configState . timerId ) ;
458
+ }
459
+
455
460
// Call each of the shutdown functions in parallel
456
461
var completed = 0 ;
457
462
var error ;
Original file line number Diff line number Diff line change
1
+ "use strict" ;
2
+ var test = require ( 'tape' )
3
+ , path = require ( 'path' )
4
+ , sandbox = require ( 'sandboxed-module' ) ;
5
+
6
+ test ( 'Reload configuration shutdown hook' , function ( t ) {
7
+ var timerId
8
+ , log4js = sandbox . require (
9
+ '../../lib/log4js' ,
10
+ {
11
+ globals : {
12
+ clearInterval : function ( id ) {
13
+ timerId = id ;
14
+ } ,
15
+ setInterval : function ( fn , time ) {
16
+ return "1234" ;
17
+ }
18
+ }
19
+ }
20
+ ) ;
21
+
22
+ log4js . configure (
23
+ path . join ( __dirname , 'test-config.json' ) ,
24
+ { reloadSecs : 30 }
25
+ ) ;
26
+
27
+ t . plan ( 1 ) ;
28
+ log4js . shutdown ( function ( ) {
29
+ t . equal ( timerId , "1234" , "Shutdown should clear the reload timer" ) ;
30
+ t . end ( ) ;
31
+ } ) ;
32
+
33
+ } ) ;
Original file line number Diff line number Diff line change
1
+ {
2
+ "appenders" : [
3
+ { "type" : " stdout" }
4
+ ]
5
+ }
You can’t perform that action at this time.
0 commit comments