mirror of
https://github.com/samsonjs/ThePusher.git
synced 2026-04-27 15:07:43 +00:00
fix up output, display receive-hook URL on startup
This commit is contained in:
parent
eabe7ea220
commit
4eb1cc7b51
1 changed files with 18 additions and 6 deletions
24
pusher.js
24
pusher.js
|
|
@ -13,6 +13,7 @@ var crypto = require('crypto')
|
||||||
, fs = require('fs')
|
, fs = require('fs')
|
||||||
, http = require('http')
|
, http = require('http')
|
||||||
, querystring = require('querystring')
|
, querystring = require('querystring')
|
||||||
|
, spawn = require('child_process').spawn
|
||||||
, server = http.createServer(routeRequest)
|
, server = http.createServer(routeRequest)
|
||||||
, serverOptions = { host: '127.0.0.1'
|
, serverOptions = { host: '127.0.0.1'
|
||||||
, port: 6177
|
, port: 6177
|
||||||
|
|
@ -73,7 +74,7 @@ function parseLine(line) {
|
||||||
process.env.PUSHER_GITHUB_TOKEN = val
|
process.env.PUSHER_GITHUB_TOKEN = val
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
console.warn('>>> unrecognized variable: ' + name + ' = ' + val)
|
console.warn('??? unrecognized variable: ' + name + ' = ' + val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -85,7 +86,7 @@ function parseLine(line) {
|
||||||
if (refType === 'tag' && (action === 'force' || action === 'merge')) {
|
if (refType === 'tag' && (action === 'force' || action === 'merge')) {
|
||||||
throw new Error(action + ' is not supported with tags, try create or delete')
|
throw new Error(action + ' is not supported with tags, try create or delete')
|
||||||
}
|
}
|
||||||
console.log('>>> ' + line)
|
console.log('* Trigger: ' + line)
|
||||||
addTrigger({ action: action
|
addTrigger({ action: action
|
||||||
, refType: refType
|
, refType: refType
|
||||||
, refSpec: ref.spec
|
, refSpec: ref.spec
|
||||||
|
|
@ -231,9 +232,8 @@ function routeRequest(req, res) {
|
||||||
|
|
||||||
function runCommand(options) {
|
function runCommand(options) {
|
||||||
console.log('>>> running command: ' + options.command)
|
console.log('>>> running command: ' + options.command)
|
||||||
var spawn = require('child_process').spawn
|
// TODO quoting
|
||||||
// TODO quoting
|
var args = options.command.split(/\s+/)
|
||||||
, args = options.command.split(/\s+/)
|
|
||||||
, cmd = args.shift()
|
, cmd = args.shift()
|
||||||
process.env.PUSHER_ACTION = options.action || ''
|
process.env.PUSHER_ACTION = options.action || ''
|
||||||
process.env.PUSHER_OWNER = options.owner || ''
|
process.env.PUSHER_OWNER = options.owner || ''
|
||||||
|
|
@ -249,7 +249,19 @@ function runCommand(options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function startServer() {
|
function startServer() {
|
||||||
server.listen(serverOptions.port, serverOptions.host)
|
var host = serverOptions.host
|
||||||
|
, port = serverOptions.port
|
||||||
|
, token = serverOptions.githubToken
|
||||||
|
if (host === '0.0.0.0') {
|
||||||
|
spawn('hostname', ['-f']).stdout.on('data', function(b) {
|
||||||
|
host = String(b).trim()
|
||||||
|
console.log('>>> Listening for pushes on http://' + host + ':' + port + '/' + token)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.log('>>> Listening for pushes on http://' + host + ':' + port + '/' + token)
|
||||||
|
}
|
||||||
|
server.listen(port, host)
|
||||||
}
|
}
|
||||||
|
|
||||||
function stopServer() {
|
function stopServer() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue