Skip to content

Instantly share code, notes, and snippets.

@kacole2
Last active June 16, 2016 16:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kacole2/5d79a0519b5f2d0c6155 to your computer and use it in GitHub Desktop.
Save kacole2/5d79a0519b5f2d0c6155 to your computer and use it in GitHub Desktop.
Creating a worker with clockwork on cloudfoundry
#Read the how-to at http://www.kendrickcoleman.com/
#this is the clockwork configuration file
require File.expand_path('../../config/boot', __FILE__)
require File.expand_path('../../config/environment', __FILE__)
require 'clockwork'
include Clockwork
every(30.seconds, 'Running my reoccurring process...') { SiteDatum.myreoccurringprocess }
---
applications:
- name: webfrontend
memory: 1024M
instances: 1
path: .
domain: cfapps.io
command: bundle exec rails s -p $PORT
services:
- my-elephant-db
- name: clockwork
memory: 512MB
instances: 1
path: .
buildpack: https://github.com/ddollar/heroku-buildpack-multi.git
no-route: true
command: bundle exec clockwork lib/clock.rb
services:
- my-elephant-db
#Read the how-to at http://www.kendrickcoleman.com/
#this is the Modal file.
class SiteDatum < ActiveRecord::Base
def self.myreoccurringprocess
#DO SOME STUFF HERE
mechanize = Mechanize.new
page = mechanize.get('http://www.google.com')
puts page.title
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment