Heroku调度程序调用作业,但未执行

如何解决Heroku调度程序调用作业,但未执行

我正在用Heroku托管我的应用程序,并且在scheduler.rake文件中有一个任务(由Heroku Scheduler调用):

task :send_recipe_summary => :environment do
  puts "Calling send recipe summary slack message job..."
  SendRecipeSummarySlackMessageJob.perform_later
  puts "Done!"
end

(通过调度程序或在控制台中)调用此任务时,它表示该任务已排队:

➜  Plant-as-Usual-2 git:(master) heroku run bundle exec rake send_recipe_summary
Running bundle exec rake send_recipe_summary on ⬢ plant-as-usual-2... up,run.5548 (Hobby)
Calling send recipe summary slack message job...
I,[2020-09-24T16:25:50.193685 #4]  INFO -- : [ActiveJob] Enqueued SendRecipeSummarySlackMessageJob (Job ID: a4110651-a9fa-4030-96ef-db4caf64c7e5) to Async(default)
Done!

但是,在日志中,作业不会排队,并且Slack消息也永远不会发送:

2020-09-24T16:25:35.913315+00:00 app[api]: Starting process with command `bundle exec rake send_recipe_summary` by user jonappleseed@email.com
2020-09-24T16:25:44.008993+00:00 heroku[run.5548]: Awaiting client
2020-09-24T16:25:44.039520+00:00 heroku[run.5548]: State changed from starting to up
2020-09-24T16:25:44.291580+00:00 heroku[run.5548]: Starting process with command `bundle exec rake send_recipe_summary`
2020-09-24T16:25:49.334067+00:00 app[worker.1]: D,[2020-09-24T16:25:49.333949 #4] DEBUG -- :   [1m[36mDelayed::Backend::ActiveRecord::Job Load (1.5ms)[0m  [1m[37mUPDATE "delayed_jobs" SET locked_at = '2020-09-24 16:25:49.331558',locked_by = 'host:9b1fc7b1-4107-427f-8f49-f058b41b7906 pid:4' WHERE id IN (SELECT "delayed_jobs"."id" FROM "delayed_jobs" WHERE ((run_at <= '2020-09-24 16:25:49.330595' AND (locked_at IS NULL OR locked_at < '2020-09-24 12:25:49.330627') OR locked_by = 'host:9b1fc7b1-4107-427f-8f49-f058b41b7906 pid:4') AND failed_at IS NULL) ORDER BY priority ASC,run_at ASC LIMIT 1 FOR UPDATE) RETURNING *[0m
2020-09-24T16:25:53.372387+00:00 heroku[run.5548]: Process exited with status 0
2020-09-24T16:25:53.407641+00:00 heroku[run.5548]: State changed from up to complete
2020-09-24T16:26:49.394474+00:00 app[worker.1]: D,[2020-09-24T16:26:49.394376 #4] DEBUG -- :   [1m[36mDelayed::Backend::ActiveRecord::Job Load (1.5ms)[0m  [1m[37mUPDATE "delayed_jobs" SET locked_at = '2020-09-24 16:26:49.392377',locked_by = 'host:9b1fc7b1-4107-427f-8f49-f058b41b7906 pid:4' WHERE id IN (SELECT "delayed_jobs"."id" FROM "delayed_jobs" WHERE ((run_at <= '2020-09-24 16:26:49.391803' AND (locked_at IS NULL OR locked_at < '2020-09-24 12:26:49.391827') OR locked_by = 'host:9b1fc7b1-4107-427f-8f49-f058b41b7906 pid:4') AND failed_at IS NULL) ORDER BY priority ASC,run_at ASC LIMIT 1 FOR UPDATE) RETURNING *[0m

但是,如果我自己运行作业(而不是任务),那么一切都会按预期进行,并且消息确实会发送:

irb(main):002:0> SendRecipeSummarySlackMessageJob.perform_later
I,[2020-09-24T16:22:45.268729 #4]  INFO -- : [ActiveJob] Enqueued SendRecipeSummarySlackMessageJob (Job ID: 8285bb7f-9646-42bb-9901-8d219ca1175c) to Async(default)
=> #<SendRecipeSummarySlackMessageJob:0x000055b1a768dfb8 @arguments=[],@job_id="8285bb7f-9646-42bb-9901-8d219ca1175c",@queue_name="default",@priority=nil,@executions=0,@exception_executions={},@provider_job_id="c41cedd7-e5a5-4a7d-9e64-280d2ec81e1e">
irb(main):003:0> I,[2020-09-24T16:22:45.269348 #4]  INFO -- : [ActiveJob] [SendRecipeSummarySlackMessageJob] [8285bb7f-9646-42bb-9901-8d219ca1175c] Performing SendRecipeSummarySlackMessageJob (Job ID: 8285bb7f-9646-42bb-9901-8d219ca1175c) from Async(default) enqueued at 2020-09-24T16:22:45Z
D,[2020-09-24T16:22:46.412105 #4] DEBUG -- : [ActiveJob] [SendRecipeSummarySlackMessageJob] [8285bb7f-9646-42bb-9901-8d219ca1175c]    (1.5ms)  SELECT COUNT(*) FROM "recipes" WHERE "recipes"."state" = $1  [["state","awaiting_approval"]]
D,[2020-09-24T16:22:46.413683 #4] DEBUG -- : [ActiveJob] [SendRecipeSummarySlackMessageJob] [8285bb7f-9646-42bb-9901-8d219ca1175c]    (1.0ms)  SELECT COUNT(*) FROM "recipes" WHERE "recipes"."state" = $1  [["state","incomplete"]]
I,[2020-09-24T16:22:46.415123 #4]  INFO -- : [ActiveJob] [SendRecipeSummarySlackMessageJob] [8285bb7f-9646-42bb-9901-8d219ca1175c] Enqueued SendSlackMessageJob (Job ID: c640b706-9920-4639-a1a0-4c7dbec15c39) to Async(default) with arguments: "There are no recipes awaiting approval,and 1 incomplete recipe https://www.plantasusual.com/admin",{:nature=>"inform"}
I,[2020-09-24T16:22:46.415260 #4]  INFO -- : [ActiveJob] [SendRecipeSummarySlackMessageJob] [8285bb7f-9646-42bb-9901-8d219ca1175c] Performed SendRecipeSummarySlackMessageJob (Job ID: 8285bb7f-9646-42bb-9901-8d219ca1175c) from Async(default) in 1145.43ms
I,[2020-09-24T16:22:46.415882 #4]  INFO -- : [ActiveJob] [SendSlackMessageJob] [c640b706-9920-4639-a1a0-4c7dbec15c39] Performing SendSlackMessageJob (Job ID: c640b706-9920-4639-a1a0-4c7dbec15c39) from Async(default) enqueued at 2020-09-24T16:22:46Z with arguments: "There are no recipes awaiting approval,[2020-09-24T16:22:46.591446 #4]  INFO -- : [ActiveJob] [SendSlackMessageJob] [c640b706-9920-4639-a1a0-4c7dbec15c39] Performed SendSlackMessageJob (Job ID: c640b706-9920-4639-a1a0-4c7dbec15c39) from Async(default) in 175.12ms

有人可以帮助我理解为什么从控制台运行时作业能按预期运行,但是从调度程序运行时却无法正常工作吗?

感谢任何可以提供帮助的人!

解决方法

似乎您尚未在heroku bundle exec rake jobs:work上启用worker。 这是一项付费服务​​。转到:your_app>“资源”选项卡,然后从那里启用它。 this link could be helpful

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-