Showing with 14 additions and 9 deletions.
  1. +2 −0 CHANGELOG
  2. +1 −1 Modulefile
  3. +2 −2 files/webhook
  4. +9 −6 templates/webhook.init.erb
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
2.2.3 - Zack Smith
* Remove PID file creation from webhook
2.1.2 - Garrett Honeycutt & Zack Smith
* Fix quoting issue created by #24 with booleans with #54
* Intial commit of fucntional tested github authenticated webhook
Expand Down
2 changes: 1 addition & 1 deletion Modulefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name 'zack-r10k'
version '2.2.2'
version '2.2.3'
source 'https://github.com/acidprime/r10k'
author 'zack'
license 'Apache License, Version 2.0'
Expand Down
4 changes: 2 additions & 2 deletions files/webhook
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ end
ENV['HOME'] = '/var/lib/peadmin'
ENV['PATH'] = '/sbin:/usr/sbin:/bin:/usr/bin:/opt/puppet/bin'

$logger = WEBrick::Log::new($config['logfile'], WEBrick::Log::INFO)
$logger = WEBrick::Log::new($config['logfile'], WEBrick::Log::DEBUG)


opts = {
Expand Down Expand Up @@ -61,6 +61,7 @@ class Server < Sinatra::Base
# curl -d '{ "ref": "refs/heads/production" }' -H "Accept: application/json" 'https://puppet:puppet@localhost:8088/payload' -k -q
post '/payload' do
protected! if $config['protected']
$logger.info("authenticated: #{$config['user']}")
request.body.rewind # in case someone already read it
data = JSON.parse(request.body.read, :quirks_mode => true)
branch = data['ref'].split("/").last
Expand Down Expand Up @@ -119,6 +120,5 @@ class Server < Sinatra::Base
end

Rack::Handler::WEBrick.run(Server, opts) do |server|
server.start { File.open("#{PIDFILE}", 'w', 0644) { |f| f.write(Process.pid.to_s) } }
[:INT, :TERM].each { |sig| trap(sig) { server.stop } }
end
15 changes: 9 additions & 6 deletions templates/webhook.init.erb
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,21 @@ stop() {
echo -n $"Stopping webhook: "
pid=`netstat -lnp | awk '/.*:8088.*ruby/{sub("/.*","",$NF);print $NF}'`
#killproc -p $pidfile $webhook]
kill -9 $pid | failure 'webhook'
RETVAL=$?
success 'webhook'
return $RETVAL
if kill -9 $pid ; then
success 'webhook'
return 0
else
failure 'webhook'
return 1
fi
}

restart() {
stop
start
}

rh_status() {
status() {
if [ -f "${pidfile}" ]; then
status -p $pidfile $webhook
RETVAL=$?
Expand All @@ -65,7 +68,7 @@ case "$1" in
restart
;;
status)
rh_status
status
;;
*)
echo $"Usage: $0 {start|stop|status|restart}"
Expand Down