@@ -12,10 +12,12 @@ var store = require('seneca-postgresql-store');
12
12
var dgram = require ( 'dgram' ) ;
13
13
var service = 'cp-events-service' ;
14
14
var sanitizeHtml = require ( 'sanitize-html' ) ;
15
- var log = require ( 'cp-logs-lib' ) ( { name : service , level : 'warn' } ) ;
15
+ var log = require ( 'cp-logs-lib' ) ( { name : service , level : 'warn' } ) ;
16
16
config . log = log . log ;
17
17
18
- seneca . log . info ( 'using config' , JSON . stringify ( config , null , 4 ) ) ;
18
+ if ( process . env . NODE_ENV !== 'production' ) {
19
+ seneca . log . info ( 'using config' , JSON . stringify ( config , null , 4 ) ) ;
20
+ }
19
21
seneca . options ( config ) ;
20
22
/**
21
23
* TextArea fields contains user generated html.
@@ -39,26 +41,33 @@ seneca.options.sanitizeTextArea = {
39
41
} ;
40
42
seneca . decorate ( 'customValidatorLogFormatter' , require ( './lib/custom-validator-log-formatter' ) ) ;
41
43
seneca . use ( store , config [ 'postgresql-store' ] ) ;
42
- seneca . use ( require ( './lib/cd-events' ) , { logger : log . logger } ) ;
44
+ seneca . use ( require ( './lib/cd-events' ) , { logger : log . logger } ) ;
43
45
seneca . use ( require ( 'cp-permissions-plugin' ) , {
44
46
config : __dirname + '/config/permissions'
45
47
} ) ;
46
48
47
49
seneca . use ( require ( 'seneca-queue' ) ) ;
48
50
seneca . use ( require ( 'seneca-kue' ) ) ;
49
- seneca . use ( require ( './lib/queues' ) , { config : config . kue } ) ;
51
+ seneca . use ( require ( './lib/queues' ) , { config : config . kue } ) ;
52
+
50
53
process . on ( 'SIGINT' , shutdown ) ;
51
54
process . on ( 'SIGTERM' , shutdown ) ;
52
55
process . on ( 'uncaughtException' , shutdown ) ;
53
56
process . on ( 'SIGUSR2' , shutdown ) ;
54
57
55
58
function shutdown ( err ) {
56
- var stopQueue = seneca . export ( 'queues/queue' ) [ ' stopQueue' ] ;
59
+ var stopQueue = seneca . export ( 'queues/queue' ) . stopQueue ;
57
60
stopQueue ( ) ;
58
- if ( err !== void 0 && err . stack !== void 0 ) {
59
- console . error ( new Date ( ) . toString ( ) + ' FATAL: UncaughtException, please report: ' + util . inspect ( err ) ) ;
60
- console . error ( util . inspect ( err . stack ) ) ;
61
- console . trace ( ) ;
61
+ if ( err !== undefined ) {
62
+ var error = {
63
+ date : new Date ( ) . toString ( ) ,
64
+ msg : err . stack !== undefined
65
+ ? 'FATAL: UncaughtException, please report: ' + util . inspect ( err . stack )
66
+ : 'FATAL: UncaughtException, no stack trace' ,
67
+ err : util . inspect ( err )
68
+ } ;
69
+ console . error ( JSON . stringify ( error ) ) ;
70
+ process . exit ( 1 ) ;
62
71
}
63
72
process . exit ( 0 ) ;
64
73
}
@@ -86,7 +95,11 @@ require('./migrate-psql-db.js')(function (err) {
86
95
seneca . wrap ( 'role: entity, cmd: ' + cmd , function filterFields ( args , cb ) {
87
96
try {
88
97
[ 'limit$' , 'skip$' ] . forEach ( function ( field ) {
89
- if ( args . q [ field ] && args . q [ field ] !== 'NULL' && ! / ^ [ 0 - 9 ] + $ / g. test ( args . q [ field ] + '' ) ) {
98
+ if (
99
+ args . q [ field ] &&
100
+ args . q [ field ] !== 'NULL' &&
101
+ ! / ^ [ 0 - 9 ] + $ / g. test ( args . q [ field ] + '' )
102
+ ) {
90
103
throw new Error ( 'Expect limit$, skip$ to be a number' ) ;
91
104
}
92
105
} ) ;
0 commit comments