Created
January 4, 2014 00:29
-
-
Save billjohnston/8249600 to your computer and use it in GitHub Desktop.
Make a scheduled node process w/ heroku scheduler
This file contains hidden or 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
.DS_Store | |
node_modules/ | |
.nodemonignore |
This file contains hidden or 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
var Mailgun = require('mailgun').Mailgun; | |
var mg = new Mailgun(process.env.MAILGUN_API_KEY); | |
mg.sendText('[email protected]', ['[email protected]'], | |
'This is the subject', | |
'This is the text', | |
'[email protected]', {}, | |
function(err) { | |
if (err) console.log('Oh noes: ' + err); | |
else console.log('Success'); | |
}); |
This file contains hidden or 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
{ | |
"name": "heroku_scheduler_test", | |
"version": "0.0.1", | |
"private": true, | |
"engines": { | |
"node": "0.10.x" | |
}, | |
"dependencies": { | |
"mailgun": "*" | |
} | |
} |
This file contains hidden or 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
git init | |
git commit -am 'Initial commit' | |
heroku create | |
(optional, set env vars. access with 'process.env.MAILGUN_API_KEY') | |
heroku config:set MAILGUN_API_KEY=your_api_key | |
heroku addons:add scheduler | |
heroku addons:open scheduler | |
(This will open the heroku page to manage scheduled jobs. For this example you would put task:node mail with the desired frequency) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment