@@ -25,6 +25,8 @@ const internalNginx = {
2525     * @returns  {Promise } 
2626     */ 
2727    configure : ( model ,  host_type ,  host )  =>  { 
28+         let  combined_meta  =  { } ; 
29+ 
2830        return  internalNginx . test ( ) 
2931            . then ( ( )  =>  { 
3032                // Nginx is OK 
@@ -39,30 +41,46 @@ const internalNginx = {
3941                return  internalNginx . test ( ) 
4042                    . then ( ( )  =>  { 
4143                        // nginx is ok 
44+                         combined_meta  =  _ . assign ( { } ,  host . meta ,  { 
45+                             nginx_online : true , 
46+                             nginx_err :    null 
47+                         } ) ; 
48+ 
4249                        return  model 
4350                            . query ( ) 
4451                            . where ( 'id' ,  host . id ) 
4552                            . patch ( { 
46-                                 meta : _ . assign ( { } ,  host . meta ,  { 
47-                                     nginx_online : true , 
48-                                     nginx_err :    null 
49-                                 } ) 
53+                                 meta : combined_meta 
5054                            } ) ; 
5155                    } ) 
5256                    . catch ( err  =>  { 
57+                         // Remove the error_log line because it's a docker-ism false positive that doesn't need to be reported. 
58+                         // It will always look like this: 
59+                         //   nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (6: No such device or address) 
60+ 
61+                         let  valid_lines  =  [ ] ; 
62+                         let  err_lines    =  err . message . split ( "\n" ) ; 
63+                         err_lines . map ( function  ( line )  { 
64+                             if  ( line . indexOf ( '/var/log/nginx/error.log' )  ===  - 1 )  { 
65+                                 valid_lines . push ( line ) ; 
66+                             } 
67+                         } ) ; 
68+ 
5369                        if  ( debug_mode )  { 
54-                             logger . error ( 'Nginx test failed:' ,  err . message ) ; 
70+                             logger . error ( 'Nginx test failed:' ,  valid_lines . join ( "\n" ) ) ; 
5571                        } 
5672
5773                        // config is bad, update meta and delete config 
74+                         combined_meta  =  _ . assign ( { } ,  host . meta ,  { 
75+                             nginx_online : false , 
76+                             nginx_err :    valid_lines . join ( "\n" ) 
77+                         } ) ; 
78+ 
5879                        return  model 
5980                            . query ( ) 
6081                            . where ( 'id' ,  host . id ) 
6182                            . patch ( { 
62-                                 meta : _ . assign ( { } ,  host . meta ,  { 
63-                                     nginx_online : false , 
64-                                     nginx_err :    err . message 
65-                                 } ) 
83+                                 meta : combined_meta 
6684                            } ) 
6785                            . then ( ( )  =>  { 
6886                                return  internalNginx . deleteConfig ( host_type ,  host ,  true ) ; 
@@ -71,7 +89,10 @@ const internalNginx = {
7189            } ) 
7290            . then ( ( )  =>  { 
7391                return  internalNginx . reload ( ) ; 
74-             } ) ; 
92+             } ) 
93+             . then ( ( )  =>  { 
94+                 return  combined_meta ; 
95+             } ) 
7596    } , 
7697
7798    /** 
@@ -82,7 +103,7 @@ const internalNginx = {
82103            logger . info ( 'Testing Nginx configuration' ) ; 
83104        } 
84105
85-         return  utils . exec ( '/usr/sbin/nginx -t' ) ; 
106+         return  utils . exec ( '/usr/sbin/nginx -t -g "error_log off;" ' ) ; 
86107    } , 
87108
88109    /** 
0 commit comments