gpt4 book ai didi

docker - 在heroku上为docker dyno运行一次性命令

转载 作者:行者123 更新时间:2023-12-02 19:56:09 25 4
gpt4 key购买 nike

当我从 clischeduler 附加组件运行工作人员测功机时,什么也没有发生。

我试图启用或禁用测功机,但它对一次性和调度程序没有任何作用。
启用 dyno 时,heroku 会启动它(不是一次性或调度程序),并且来自 worker 的命令(在 Dockerfile 中指定为 CMD)运行得很好。
使用命令运行 run 也无济于事。
此类运行的日志输出如下所示:

2019-09-04T18:30:34.176982+00:00 heroku[scheduler.8210]: State changed from starting to complete

2019-09-04T18:30:34.153189+00:00 app[api]: Starting process with command `/opt/app/run.sh` by user scheduler@addons.heroku.com

2019-09-04T18:41:15.398424+00:00 heroku[scheduler.4565]: State changed from starting to complete

2019-09-04T18:41:15.354628+00:00 app[api]: Starting process with command `/opt/app/run.sh` by user scheduler@addons.heroku.com

启用测功机后运行的日志输出如下:
2019-09-04T18:45:39.694515+00:00 app[api]: Scaled to worker@1:Free by user kjiec4@gmail.com

2019-09-04T18:45:44.856180+00:00 heroku[worker.1]: Starting process with command `/opt/app/run.sh`

2019-09-04T18:45:45.474477+00:00 heroku[worker.1]: State changed from starting to up

2019-09-04T18:45:47.252345+00:00 app[worker.1]: [main] INFO org.flywaydb.core.internal.license.VersionPrinter - Flyway Community Edition 6.0.1 by Boxfuse

2019-09-04T18:45:48.221494+00:00 app[worker.1]: [main] INFO org.flywaydb.core.internal.database.DatabaseFactory - Database: jdbc:postgresql://ec2-176-34-184-174.eu-west-1.compute.amazonaws.com:5432/dc9jgd0q28f9sd (PostgreSQL 11.5)

2019-09-04T18:45:48.298740+00:00 app[worker.1]: [main] INFO org.flywaydb.core.internal.command.DbValidate - Successfully validated 1 migration (execution time 00:00.037s)

2019-09-04T18:45:48.321407+00:00 app[worker.1]: [main] INFO org.flywaydb.core.internal.schemahistory.JdbcTableSchemaHistory - Creating Schema History table "public"."flyway_schema_history" ...

2019-09-04T18:45:48.383992+00:00 app[worker.1]: [main] INFO org.flywaydb.core.internal.command.DbMigrate - Current version of schema "public": << Empty Schema >>

2019-09-04T18:45:48.392490+00:00 app[worker.1]: [main] INFO org.flywaydb.core.internal.command.DbMigrate - Migrating schema "public" to version 1 - Create news table

2019-09-04T18:45:48.422169+00:00 app[worker.1]: [main] INFO org.flywaydb.core.internal.command.DbMigrate - Successfully applied 1 migration to schema "public" (execution time 00:00.052s)

2019-09-04T18:46:08.425628+00:00 heroku[worker.1]: State changed from up to crashed

2019-09-04T18:46:08.509950+00:00 heroku[worker.1]: State changed from crashed to starting

2019-09-04T18:46:08.401741+00:00 heroku[worker.1]: Process exited with status 0

2019-09-04T18:46:12.919303+00:00 heroku[worker.1]: Starting process with command `/opt/app/run.sh`

2019-09-04T18:46:13.527541+00:00 heroku[worker.1]: State changed from starting to up

最后一个是预期的行为。

我正在尝试像这样运行它:
heroku run worker

像这样:
heroku run worker /opt/app/run.sh

调度程序命令简单地指定为: worker

我应该怎么做才能在heroku中一次性运行docker容器?

最佳答案

好吧,正如我发现的那样,我做错了一切。
cli 一次性运行需要指定进程类型作为参数:

heroku run worker --type=worker

至于 scheduler插件,它仅适用于 web如文档中所述的测功机:

If you are using Heroku Scheduler and Container Registry as your deployment method, your task must be accessible from the web image. There is no way to specify a non-web image for task execution.



https://devcenter.heroku.com/articles/scheduler

关于docker - 在heroku上为docker dyno运行一次性命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57794265/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com