This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# We included ActionMailer and our mailer models in the code package | |
# in the last step, but we still need to require them in our worker file. | |
require 'active_support/core_ext' | |
require 'action_mailer' | |
require 'models/mailer' | |
# Parse our config yaml file | |
config = YAML.load_file("settings.yml") | |
# A nifty Ruby line to set the AM settings from our loaded yaml file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sendgrid: | |
address: "smtp.sendgrid.net" | |
port: '25' | |
authentication: :plain | |
domain: | |
user_name: | |
password: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"token":"YOUR_TOKEN", | |
"project_id":"YOUR_PROJECT_ID" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://worker-aws-us-east-1.iron.io/2/projects/{PROJECT_ID}/tasks/webhook?code_name=TwilioWebhook&oauth={TOKEN} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
worker_client.schedules.create('SendInsanity', | |
{ | |
:number => number, | |
:config => worker_client.api.options | |
}, | |
{ | |
:start_at => Time.now, | |
:run_times => 5, | |
:run_every => 60 | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Scheduling a task to be queued at a specific time (eg. 1 hour from now) | |
schedule = client.schedules.create('MyWorker', payload, | |
{:start_at => Time.now + 3600}) | |
# Running a task repeatedly (eg. every hour) | |
schedule = client.schedules.create('MyWorker', payload, | |
{:run_every => 3600}) | |
# Scheduling a task to run until a certain time (eg. run 3 hours then stop) | |
schedule = client.schedules.create('MyWorker', payload, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts "Starting HelloWorker at #{Time.now}" | |
puts `curl http://ec2-184-72-163-60.compute-1.amazonaws.com --connect-timeout 10` | |
puts "done" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tasks import add | |
import time | |
start=time.time() | |
for i in range(1000): | |
add.delay(1,i) | |
print "queued job %x" % (i) | |
print "finished in %x seconds" % (time.time() - start) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from celery import Celery | |
import iron_celery | |
celery = Celery('tasks', broker='amqp://guest@localhost//') | |
@celery.task | |
def add(x, y): | |
return x + y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from celery import Celery | |
import iron_celery | |
celery = Celery('tasks', | |
broker='ironmq://{iron_project_id}:{iron_token}@') | |
@celery.task | |
def add(x, y): | |
return x + y |