Skip to content
This repository was archived by the owner on Feb 26, 2021. It is now read-only.

Commit

Permalink
feat: add bin.js
Browse files Browse the repository at this point in the history
  • Loading branch information
mkg20001 committed Jan 10, 2019
1 parent d77e5a0 commit 13b63dd
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/server/bin.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
'use strict'

// Usage: $0 [<address> <address 2>...]

/* eslint-disable no-console */

const Server = require('.')

const server = new Server({})
let addresses = process.argv.slice(2)
if (!addresses.length) { addresses = null } // use default if none provided

const server = new Server({ addresses })
server.start().then(() => {
console.log('Started!')
})
server.switch.addresses.map(String).forEach(addr => console.log('Listening on %s', addr))
}, err)

function stop () {
console.log('Stopping...')
server.stop().then(() => process.exit(0), err)
}

function err (err) {
console.error(err.stack)
process.exit(2)
}

process.on('SIGTERM', stop)
process.on('SIGINT', stop)

0 comments on commit 13b63dd

Please sign in to comment.