假设有一个任务
rake startupscript
它应该在应用程序启动时运行,我们如何在heroku上自动化它?
我知道有一个 heroku 调度程序,但它会每 10 分钟运行一次任务,而不是只在启动时运行一次。我也知道Procfile https://devcenter.heroku.com/articles/procfile并相信这可以是一个解决方案,尽管我还不知道如何实现(可能更重要的是,我不想冒险破坏可以通过 Procfile 配置的任何其他内容,例如网络服务器等)。许多 Procfile 文档侧重于使用它来更改 Web 服务器而不是应用程序级别的 rake 任务。
如何使 rake 任务在启动时运行?
在启动应用程序服务之前,您可以将类似的内容添加到 Procfile 中
# Run pre-release-tasks here
release: bundle exec rails db:migrate
# Then run your application
web: bundle exec puma -t 5:5 -p ${PORT:-3000} -e ${RACK_ENV:-development}
任何标记为release
将在启动脚本运行之前运行
https://devcenter.heroku.com/articles/release-phase https://devcenter.heroku.com/articles/release-phase
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)