forked from OpenROV-Dev/mjpeg-video-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
59 lines (50 loc) · 1.86 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Test With:
// DEBUG="app:*" node App.js -p 8300 -c "data.pem" -k "key.pem"
// To eliminate hard coding paths for require, we are modifying the NODE_PATH to include our lib folder
var nodepath = __dirname + "/:" +
__dirname + "/lib/:" +
process.env[ "COCKPIT_PATH" ] + "/lib:" +
( ( process.env[ "NODE_PATH" ] !== undefined ) ? process.env[ "NODE_PATH" ] : "" );
process.env["NODE_PATH"] = nodepath;
require( "module" ).Module._initPaths();
// Logging utilities
const log = require( "debug" )( "app:log" );
const error = require( "debug" )( "app:error" );
// Parse command line arguments
var argv = require( "yargs" )
.usage( "Usage: $0 -p [port number] -c [certificate path] -k [key path]" )
.number( "p" )
.string( "c" )
.string( "k" )
.boolean( "m" )
.boolean( "h" )
.demand( [ "p", "c", "k" ] )
.fail( function (msg, err)
{
error( "Error parsing arguments: " + msg );
error( "Exiting..." );
process.exit( 1 );
})
.argv;
try
{
var settings =
{
port: argv.p, // Supervisor socket.io port number
cert: argv.c, // Absolute SSL Cert Path
key: argv.k, // Absolute SSL Key Path
useMock: ( ( argv.m !== undefined ) ? argv.m : false ), // Use mock mode
useHardware: ( ( argv.h !== undefined ) ? argv.h : false ) // Use real hardware (true) or mock hardware (false)
}
// Create supervisor
const Supervisor = require( "Supervisor" );
const supervisor = new Supervisor( settings );
// Run supervisor
supervisor.run();
}
catch( err )
{
error( "Error running supervisor: " + err );
error( "Exiting..." );
process.exit( 2 );
}