Skip to content

Commit

Permalink
Finished up heroku ps support
Browse files Browse the repository at this point in the history
  • Loading branch information
vongrippen committed Mar 26, 2013
1 parent cf0f271 commit 6ea2d7f
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions heroku.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# A simple interaction with Heroku command line
#
# Dependencies:
# "heroku": "git://github.com/vongrippen/node-heroku.git"
# "heroku": "https://github.com/vongrippen/node-heroku.git"
#
# Notes:
# Dependency should change once pull request is accepted and released to npm
Expand All @@ -16,6 +16,8 @@
# hubot heroku <app> config:unset <variable> - Delete a config var for an app
# hubot heroku <app> ps - List running Heroku processes for an app
# hubot heroku <app> ps:restart [process] - Restart Heroku process or all processes
# hubot heroku <app> ps:scale <process>=<count> - Scale Heroku processes
# hubot heroku <app> ps:stop <process> - Stop Heroku process (restarts on a new dyno)
heroku = new (require("heroku")).Heroku({key: process.env.HUBOT_HEROKU_API_KEY})

nodelog = (error, result)->
Expand Down Expand Up @@ -64,7 +66,7 @@ module.exports = (robot)->
# herok ps
#
###
robot.respond /heroku (.*) ps$/i, (msg)->
herokuPs = (msg)->
heroku.get_ps msg.match[1], (error, result)->
nodelog error, result
processes = {}
Expand All @@ -88,10 +90,20 @@ module.exports = (robot)->
output.push ''
msg.send output.join "\n"

robot.respond /heroku (.*) ps$/i, herokuPs

robot.respond /heroku (.*) ps:restart$/i, (msg)->
heroku.post_ps_restart msg.match[1], (error, result)->
msg.send result
heroku Ps msg

robot.respond /heroku (.*) ps:restart (.*)/i, (msg)->
heroku.post_ps_restart msg.match[1], {ps: msg.match[2]}, (error, result)->
msg.send result
heroku Ps msg

robot.respond /heroku (.*) ps:scale (.*)=(.*)/i, (msg)->
heroku.post_ps_scale msg.match[1], msg.match[2], msg.match[3], (error, result)->
heroku Ps msg

robot.respond /heroku (.*) ps:stop (.*)/i, (msg)->
heroku.post_ps_stop msg.match[1], {ps: msg.match[2]}, (error, result)->
heroku Ps msg

0 comments on commit 6ea2d7f

Please sign in to comment.