gpt4 book ai didi

ruby - 如何让 Heroku 从工作进程登录?

转载 作者:行者123 更新时间:2023-12-05 03:12:21 25 4
gpt4 key购买 nike

我正在尝试让 Heroku 运行一个简单的 Ruby 进程并写入 Logplex。

我的文件:

worker: ruby test_app.rb

test_app.rb:

puts 'LOGGGGG!'
raise 'we have a problem'
sleep(10)

当我在本地运行 heroku 时,我得到了预期的输出:

forego  | starting worker.1 on port 5000
worker.1 | test_app.rb:10:in `<main>': we have a problem (RuntimeError)
worker.1 | LOGGGGG!

但是当我像往常一样添加、提交和推送到 Heroku 时,我在日志中什么也得不到(heroku logs)——只有这个:

2015-11-27T17:55:39.671609+00:00 heroku[slug-compiler]: Slug compilation started
2015-11-27T17:55:39.671620+00:00 heroku[slug-compiler]: Slug compilation finished

我可能做错了什么?我不知所措...谢谢,路易丝

编辑:我的推送输出如下所示:

 1 file changed, 1 deletion(-)
Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 286 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Using set buildpack heroku/ruby
remote: -----> Ruby app detected
remote: -----> Compiling Ruby
remote: -----> Using Ruby version: ruby-2.2.2
remote: -----> Installing dependencies using bundler 1.9.7
remote: Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
remote: Using i18n 0.7.0
remote: Using json 1.8.3
remote: Using minitest 5.8.3
remote: Using thread_safe 0.3.5
remote: Using amq-protocol 2.0.0
remote: Using concurrent-ruby 1.0.0
remote: Using connection_pool 2.2.0
remote: Using netrc 0.7.9
remote: Using redis 3.2.2
remote: Using bundler 1.9.7
remote: Using tzinfo 1.2.2
remote: Using bunny 2.2.1
remote: Using rest_client 1.8.3
remote: Using sidekiq 4.0.1
remote: Using activesupport 4.2.5
remote: Bundle complete! 7 Gemfile dependencies, 15 gems now installed.
remote: Gems in the groups development and test were not installed.
remote: Bundled gems are installed into ./vendor/bundle.
remote: Bundle completed (0.26s)
remote: Cleaning up the bundler cache.
remote: -----> Writing config/database.yml to read from DATABASE_URL
remote:
remote:
remote: -----> Discovering process types
remote: Procfile declares types -> worker
remote: Default types for buildpack -> console, rake
remote:
remote: -----> Compressing... done, 18.1MB
remote: -----> Launching... done, v19
remote: https://application-name.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To git@heroku.com:application-name.git
75d764d..a7d6bdb master -> master

最佳答案

您是否在完成部署后扩展了工作进程?

heroku ps:scale worker=1 将启动一个工作进程。这样做你会得到...

2015-11-27T18:09:16.366187+00:00 heroku[slug-compiler]: Slug compilation started
2015-11-27T18:09:16.366197+00:00 heroku[slug-compiler]: Slug compilation finished
2015-11-27T18:10:14.409542+00:00 heroku[api]: Scale to web=1, worker=1 by me@me.com
2015-11-27T18:10:16.657359+00:00 heroku[worker.1]: Starting process with command `ruby test_app.rb`
2015-11-27T18:10:17.365815+00:00 heroku[worker.1]: State changed from starting to up
2015-11-27T18:10:18.668842+00:00 app[worker.1]: test_app.rb:3:in `<main>': we have a problem (RuntimeError)
2015-11-27T18:10:18.669815+00:00 app[worker.1]: LOGGGGG!
2015-11-27T18:10:19.493559+00:00 heroku[worker.1]: State changed from up to crashed

Heroku默认只会启动web进程,你需要扩容worker进程。

关于ruby - 如何让 Heroku 从工作进程登录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33962703/

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