File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change 11const express = require ( 'express' ) ;
22const os = require ( 'os' ) ;
3+ const fs = require ( 'fs' ) ;
4+ const path = require ( 'path' ) ;
5+
6+ const getColor = ( ) => {
7+ let color = process . env . DEFAULT_COLOR ;
8+ const filePath = process . env . COLOR_CONFIG_PATH ;
9+
10+ if ( filePath ) {
11+ try {
12+ const colorFromFile = fs . readFileSync ( path . resolve ( filePath ) , 'utf8' ) ;
13+
14+ color = colorFromFile . trim ( ) ;
15+ } catch ( error ) {
16+ console . error ( `Failed to read contents of ${ filePath } ` ) ;
17+ console . error ( error ) ;
18+ }
19+ }
20+
21+ return color || 'blue' ;
22+ } ;
323
424const app = express ( ) ;
525const port = 80 ;
6- const color = 'blue' ;
26+ const color = getColor ( ) ;
727const hostname = os . hostname ( ) ;
828
929const delay_startup = process . env . DELAY_STARTUP === 'true' ;
You can’t perform that action at this time.
0 commit comments