import { Config } from './connector' ; import * as _ from 'underscore' ; let host = process . env . CORE_HOST || '127.0.0.1' ; let port = parseInt ( process . env . CORE_PORT + '' , 10 ) || 3000 ; let logPath = process . env . CORE_LOG || '' ; let logLevel = process . env . LOG_LEVEL || undefined ; let deviceId = process . env . DEVICE_ID || '' ; let deviceToken = process . env . DEVICE_TOKEN || '' ; let disableWatchdog = process . env . DISABLE_WATCHDOG === '1' || false ; let unsafeSSL = process . env . UNSAFE_SSL === '1' || false ; const certs = ( process . env . CERTIFICATES || '' ) . split ( ';' ) || [ ] ; let disableAtemUpload = process . env . DISABLE_ATEM_UPLOAD === '1' || false ; let prevProcessArg = '' ; process . argv . forEach ( ( val ) => { val = val + '' ; let nextPrevProcessArg = val ; if ( prevProcessArg . match ( /-host/i ) ) { host = val ; } else if ( prevProcessArg . match ( /-port/i ) ) { port = parseInt ( val , 10 ) ; } else if ( prevProcessArg . match ( /-logLevel/i ) ) { logLevel = val ; } else if ( prevProcessArg . match ( /-log/i ) ) { logPath = val ; } else if ( prevProcessArg . match ( /-id/i ) ) { deviceId = val ; } else if ( prevProcessArg . match ( /-token/i ) ) { deviceToken = val ; } else if ( prevProcessArg . match ( /-certificates/i ) ) { certs . push ( val ) ; nextPrevProcessArg = prevProcessArg ; } else if ( val . match ( /-disableWatchdog/i ) ) { disableWatchdog = true ; } else if ( val . match ( /-disableAtemUpload/i ) ) { disableAtemUpload = true ; } else if ( val . match ( /-unsafeSSL/i ) ) { unsafeSSL = true ; } prevProcessArg = nextPrevProcessArg + '' ; } ) ; const config = { process : { unsafeSSL : unsafeSSL , certificates : _ . compact ( certs ) } , device : { deviceId : deviceId , deviceToken : deviceToken } , core : { host : host , port : port , watchdog : ! disableWatchdog } , tsr : { } } ; export { config , logPath , logLevel , disableWatchdog , disableAtemUpload } ;