【发布时间】:2017-05-01 21:12:42
【问题描述】:
我不确定我做错了什么,但我正在尝试关注this 文章。我有以下 Procfile:
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
所以我可以看到我正在启动工人(它什么都不做)然后它崩溃了。然后我的时钟启动了,但再也没有给工人打电话?它绝对不是每分钟都启动。
我关注的文章是否陈旧且不再适用?如何正确称呼工人?
【问题讨论】: