我尝试使用 heroku 插件“scheduler”运行 myFile
。
简化的文件结构(MyProject 是根)
MyProject -> bin -> myFile
我的文件
#!/usr/bin/env node
const foo = require('myFunc');
foo();
process.exit();
从我的电脑本地从 heroku-cli bash 测试 MyFile,它按预期工作。然而,我的 heroku scheduler cmd 很可能是错误的,因为当调度程序在指定时间触发时,我在日志中收到以下错误:
2018-09-05T12:00:08.323971+00:00 app[api]: Starting process with command `run eovendoEarnMoney` by user scheduler@addons.heroku.com
2018-09-05T12:01:05.759152+00:00 heroku[scheduler.4007]: Starting process with command `run myFile`
2018-09-05T12:01:06.419284+00:00 heroku[scheduler.4007]: State changed from starting to up
2018-09-05T12:01:08.283555+00:00 heroku[scheduler.4007]: State changed from up to complete
2018-09-05T12:01:08.223306+00:00 heroku[scheduler.4007]: Process exited with status 127
2018-09-05T12:01:08.154580+00:00 app[scheduler.4007]: bash: heroku: command not found
我尝试将 bash 命令(在上图中)更改为:run myFile
。导致同样的错误,只是这次的错误是:
2018-09-05T12:01:08.154580+00:00 app[scheduler.4007]: bash: run: command not found
我在 this answer 之后为 heroku-cli 添加了一个构建包因为我认为这会有所帮助。
运行“myFile”的正确命令是什么?
没有关于此事的文档
最佳答案
根据 Heroku Scheduler Documentation您应该使用 heroku run myFile
来测试命令是否在本地运行。
该文档还解释了使用 Scheduler Dashboard 中的 rails 执行此操作的方法:
For example, add
rake update_feed
, select “Hourly” and “:30” to update feeds every hour on the half-hour. Then add rake send_reminders, select “Daily” and “00:00” to send reminders every day at midnight.
因此,在您的情况下,您应该将 heroku run myFile
更改为 myFile
到 Scheduler Dashboard
关于javascript - 运行文件的 heroku scheduler 命令是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52184857/