webssh2/index.js
billchurch d849f7432e adding readyTimeout option, updating packages
adding readyTimeout option, updating packages
2017-08-21 09:21:52 -04:00

25 lines
618 B
JavaScript

// server.js
/*
* WebSSH2 - Web to SSH2 gateway
* Bill Church - https://github.com/billchurch/WebSSH2 - May 2017
*
*/
'use strict'
var config = require('./app').config
var server = require('./app').server
server.listen({ host: config.listen.ip, port: config.listen.port
})
server.on('error', function (err) {
if (err.code === 'EADDRINUSE') {
config.listen.port++
console.warn('WebSSH2 Address in use, retrying on port ' + config.listen.port)
setTimeout(function () {
server.listen(config.listen.port)
}, 250)
} else {
console.log('WebSSH2 server.listen ERROR: ' + err.code)
}
})