javascript - 运行文件的 heroku scheduler 命令是什么?

标签 javascript node.js bash heroku heroku-cli

我尝试使用 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

enter image description here

我尝试将 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/

相关文章:

bash - 每两周一次的 Crontab 计划

javascript - 需要一种简单的方法来设置空 block 元素的宽度和高度

node.js - 使用 Mongoose 更新

regex - 基于 Bash 的正则表达式域名验证

node.js - 蒙戈 : query on subdocs

node.js - apollo useLazyQuery 绕过缓存

bash - 从 bash 的新 Google Chrome 浏览器 session 中获取 "user agent"字符串

javascript - 使用 jQuery 的定期 ajax 请求超时

javascript - 正则表达式匹配除空格和最后 4 个字符以外的所有字符

javascript - 除了一个元素向右浮动外,所有内容都居中的导航栏