35 lines
831 B
JavaScript
Executable file
35 lines
831 B
JavaScript
Executable file
#!/usr/bin/env node
|
|
|
|
'use strict'
|
|
|
|
var fs = require('fs')
|
|
var options = require('../lib/options')
|
|
process.env.LAMASSU_ENV = process.env.LAMASSU_ENV || options.logLevel || 'info'
|
|
|
|
var createServer = require('../lib/app.js')
|
|
var argv = require('minimist')(process.argv.slice(2))
|
|
|
|
var port = process.env.PORT || 3000
|
|
var httpOnly = options.httpOnly || argv.http
|
|
|
|
if (!httpOnly) {
|
|
try {
|
|
options.https = {
|
|
key: fs.readFileSync(options.certKeyPath),
|
|
cert: fs.readFileSync(options.certPath)
|
|
}
|
|
} catch (err) {
|
|
console.log('Please configure your certificate.')
|
|
console.log(err)
|
|
process.exit(1)
|
|
}
|
|
}
|
|
|
|
options.mock = argv.mock
|
|
|
|
var server = createServer(options)
|
|
|
|
server.listen(port, function () {
|
|
console.log('lamassu-server listening on port ' + port + ' ' +
|
|
(httpOnly ? '(http)' : '(https)'))
|
|
})
|