2015-11-27 18 views
2

我試圖讓Heroku運行一個簡單的Ruby進程並寫入到Logplex。如何讓Heroku從工作進程登錄?

我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 [email protected]:application-name.git 
    75d764d..a7d6bdb master -> master 

回答

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 [email protected] 
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過程。