2016-02-26 49 views
0

我已经有一个超级简单的node.js任务在heroku中设置为this blog。似乎一切正常,但是当我使用heroku logs --tail时,console.log语句不显示在控制台中。为什么我的node.js heroku任务console.log语句显示在heroku日志中?

我的任务是这样的:

#!/usr/bin/env node 

var firebase = require('firebase') 
console.log('I have loaded firebase'); 

我知道它的运行,因为我没有在pacakages.json的火力NPM包,并得到了预期的错误。一旦解决,一切似乎运行良好,但我没有从我的console.log行输出。 = [

我执行任务与heroku run reconcileTasks并获得在日志尾部下面的输出:

2016-02-25T21:47:00.483677+00:00 heroku[api]: Starting process with command `reconcileTasks` by [email protected] 
2016-02-25T21:47:01.648730+00:00 heroku[run.2829]: Awaiting client 
2016-02-25T21:47:01.687472+00:00 heroku[run.2829]: Starting process with command `reconcileTasks` 
2016-02-25T21:47:01.945501+00:00 heroku[run.2829]: State changed from starting to up 
2016-02-25T21:47:03.964158+00:00 heroku[run.2829]: Process exited with status 0 
2016-02-25T21:47:03.991854+00:00 heroku[run.2829]: State changed from up to complete 

回答

0

已预约任务运行过夜后,我发现了日志显示我的消息期待。显然,console.log会转到用户将要看到的上下文。当我通过heroku run命令手动运行它时,它显示在我工作的控制台中,但是当heroku调度程序运行它时,它会显示在日志中。这是一些非常酷的魔法。 =]

2016-02-26T05:30:16.396497+00:00 heroku[api]: Starting process with command `reconcileTasks` by [email protected] 
2016-02-26T05:30:17.623505+00:00 heroku[scheduler.7098]: Starting process with command `reconcileTasks` 
2016-02-26T05:30:18.316360+00:00 heroku[scheduler.7098]: State changed from starting to up 
2016-02-26T05:30:19.866568+00:00 app[scheduler.7098]: I have loaded firebase 
2016-02-26T05:30:20.819687+00:00 heroku[scheduler.7098]: State changed from up to complete 
2016-02-26T05:30:20.805612+00:00 heroku[scheduler.7098]: Process exited with status 0 
相关问题