Skip to content

Commit

Permalink
Merge pull request #237 from github/keep-alive-ping
Browse files Browse the repository at this point in the history
Keep alive ping
  • Loading branch information
tombell committed Feb 10, 2012
2 parents 7bf5650 + 5e738f6 commit 599fed3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/robot.coffee
@@ -1,11 +1,12 @@
Fs = require 'fs'
Url = require 'url'
Log = require 'log'
Path = require 'path'
Connect = require 'connect'
Fs = require 'fs'
Url = require 'url'
Log = require 'log'
Path = require 'path'
Connect = require 'connect'
HttpClient = require 'scoped-http-client'

User = require './user'
Brain = require './brain'
User = require './user'
Brain = require './brain'

HUBOT_DEFAULT_ADAPTERS = [ "campfire", "shell" ]

Expand Down Expand Up @@ -192,6 +193,12 @@ class Robot

@connect.listen process.env.PORT || 8080

setInterval =>
HttpClient.create("http://localhost:#{process.env.PORT || 8080}/hubot/ping")
.post() (err, res, bod) =>
@logger.info "Keep alive ping!"
, 1200000

# Load the adapter Hubot is going to use.
#
# path - A String of the path to adapter if local.
Expand Down Expand Up @@ -485,9 +492,6 @@ class Robot.Response
http: (url) ->
@httpClient.create(url)

HttpClient = require 'scoped-http-client'

Robot.Response::httpClient = HttpClient

module.exports = Robot

4 changes: 4 additions & 0 deletions src/scripts/httpd.coffee
Expand Up @@ -2,12 +2,16 @@
spawn = require('child_process').spawn

module.exports = (robot) ->

robot.router.get "/hubot/version", (req, res) ->
res.end robot.version

robot.router.post "/hubot/ping", (req, res) ->
res.end "PONG"

robot.router.get "/hubot/time", (req, res) ->
res.end "Server time is: #{new Date()}"

robot.router.get "/hubot/info", (req, res) ->
child = spawn('/bin/sh', ['-c', "echo I\\'m $LOGNAME@$(hostname):$(pwd) \\($(git rev-parse HEAD)\\)"])

Expand Down

0 comments on commit 599fed3

Please sign in to comment.