如何从工作进程中获取Heroku?

时间:2015-11-27 17:58:56

标签: ruby logging heroku worker

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

我的Procfile:

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

1 个答案:

答案 0 :(得分:1)

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

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进程。