#!/usr/bin/ruby require 'json' require 'logger' while line = STDIN.gets message = JSON.load(line) status = message['body']['action'] case status when "start" system('sudo /etc/init.d/httpd start') when "stop" system('sudo /etc/init.d/httpd stop') end end