Vincent Bakker


650 Experience
6 Lessons Completed
0 Questions Solved


Posted in Mimic Heroku CLI on Hatchbox with rake tasks

Hi guys,

Weirdly enough the thing that was holding me back the most from moving away from Heroku to Hatchbox was the ease of use of the Heroku CLI in my daily workflow.

So this weekend I decided to hack together the following rake tasks to mimic heroku logs, heroku console and heroku deploy.

Display logs for the app.
rake hatchbox:logs

Connect to Rails console
rake hatchbox:console

Deploy latest version
rake hatchbox:deploy

Let me know if there is anything that needs to be changed or improved or if this is horrifically insecure. Next step might be to convert this into a gem and find a better place for the credentials.

require 'net/http'

server = "xxxx" 
app = "xxx" 
webhook = "xxx" 

namespace :hatchbox do

  desc "Display logs for the app"
  task logs: :environment do
      command = "ssh deploy@#{server} journalctl --user --unit=#{app.parameterize}-server -n 100 --no-pager"
      puts "Running #{command}..."

  desc "Connect to Rails console"
  task console: :environment do
    command = "ssh -t deploy@#{server} 'cd #{app}/current && bundle exec rails console'"
    puts "Running #{command}..."

  desc "Deploy latest version"
  task deploy: :environment do    
    uri = URI.parse(webhook)
    command =, 'latest=true') 
    puts "Deploying latest commit"