0
我不知道我在做什麼錯,但我正在嘗試遵循this文章。我有以下Procfile:Heroku自定義時鐘進程無法在每個時間間隔使用cron運行
web: node index.js
worker: node bot.js
clock: node clock.js
和我clock.js裏面,我有:
var CronJob = require('cron').CronJob;
var bot = require('./bot.js');
new CronJob({
cronTime: "* * * * *",
onTick: bot.start(),
start: true,
timeZone: "America/Los_Angeles"
});
和我bot.js的結構,像這樣:
var config = require('./config');
// ... other includes
module.exports = {
start: function() {
// code
}
}
我的結構相匹配文章非常精確,但發生了什麼?這裏是我的日誌:
2016-12-16T06:00:48.935847+00:00 heroku[web.1]: Starting process with command `node index.js`
2016-12-16T06:00:49.332925+00:00 heroku[worker.1]: Starting process with command `node bot.js`
2016-12-16T06:00:49.736519+00:00 heroku[clock.1]: Starting process with command `node clock.js`
2016-12-16T06:00:50.058125+00:00 heroku[worker.1]: State changed from starting to up
2016-12-16T06:00:50.395082+00:00 heroku[clock.1]: State changed from starting to up
2016-12-16T06:00:51.899971+00:00 app[web.1]: app running on port 21470
2016-12-16T06:00:52.505353+00:00 heroku[worker.1]: State changed from up to crashed
2016-12-16T06:00:52.491705+00:00 heroku[worker.1]: Process exited with status 0
2016-12-16T06:00:52.698864+00:00 heroku[web.1]: State changed from starting to up
所以我可以看到,我啓動了工人(什麼都不做),然後崩潰。然後我的時鐘開始工作,但再也不打電話給工人了?這絕對不是每分鐘都開始。
我跟着的文章老了,不再適用?我應該如何正確地打電話給工人?