无法使用dokku在digitalocean上部署

时间:2017-02-04 05:51:45

标签: ruby-on-rails digital-ocean dokku mailman-gem

我正在尝试使用dokku在Digital Ocean上部署我的rails应用程序(我有20美元的计划,它有2个CPU),具有新功能,即mailman,假设每隔5分钟检查/检索一次邮件。

以下是我的配置:

Procfile

web: bundle exec foreman start -f Procfile.real

Procfile.real

web: bundle exec puma -C config/puma.rb
worker: bundle exec rake jobs:work
clock: bundle exec clockwork lib/clock.rb
mailman: ruby script/mailman_server.rb

puma.rb

workers 2 
threads_count = Integer(ENV['MAX_THREADS'] || 5)
threads threads_count, threads_count

preload_app!

rackup      DefaultRackup
port        ENV['PORT']     || 3000
environment ENV['RACK_ENV'] || 'development'

on_worker_boot do
  # Worker specific setup for Rails 4.1+
  ActiveRecord::Base.establish_connection
end

clock.rb

require File.expand_path('../../config/boot',        __FILE__)
require File.expand_path('../../config/environment', __FILE__)
require 'clockwork'

include Clockwork

every(1.day, 'Run my worker daily', at: '04:30') { `rake scheduler:reminder_birthday_email` }

检查

WAIT=8 #Wait 8 seconds before each attempt
ATTEMPTS=6 #Try 6 times, if it still doesn't work, the deploy has failed and the old container (app) will be kept
/check_deploy.txt deploy_successful

在我尝试部署mailman之前,这一切都很好并且正常工作。推送每次都被拒绝。以下是日志:

Dushyants-MacBook-Pro:mywebapp dushyantagarwal$ git push staging master
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_CTYPE = "UTF-8",
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Counting objects: 51, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (48/48), done.
Writing objects: 100% (51/51), 6.12 KiB | 0 bytes/s, done.
Total 51 (delta 37), reused 0 (delta 0)
-----> Cleaning up...
-----> Building mywebapp from herokuish...
-----> Adding BUILD_ENV to build environment...
-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.1.2
-----> Installing dependencies using bundler 1.11.2
       Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
       Warning: the running version of Bundler is older than the version that created the lockfile. We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
       Using rake 10.4.2
       Using i18n 0.7.0
       Using json 1.8.3
       Using minitest 5.8.2
       Using thread_safe 0.3.5
       Using builder 3.2.2
       Using erubis 2.7.0
       Using rack 1.5.5
       Using mime-types 1.25.1
       Using polyglot 0.3.5
       Using arel 5.0.1.20140414130214
       Using bundler 1.11.2
       Using thor 0.19.1
       Using request_store 1.3.0
       Using addressable 2.3.8
       Using extlib 0.9.16
       Using multi_json 1.11.2
       Using execjs 2.6.0
       Using mini_portile 0.6.2
       Using htmlentities 4.3.4
       Using rubyzip 1.1.7
       Using bcrypt 3.1.10
       Using sass 3.4.19
       Using cancancan 1.13.1
       Using hitimes 1.2.4
       Using coffee-script-source 1.9.1.1
       Using orm_adapter 0.5.0
       Using unf_ext 0.0.7.1
       Using multipart-post 2.0.0
       Using ffi 1.9.14
       Using jwt 1.5.2
       Using little-plugger 1.1.4
       Using memoist 0.12.0
       Using retriable 1.4.1
       Using oauth 0.4.7
       Using multi_xml 0.5.5
       Using libv8 3.16.14.13
       Using rb-fsevent 0.9.8
       Using maildir 2.2.1
       Using mimemagic 0.3.0
       Using netrc 0.10.3
       Using pg 0.18.3
       Using puma 3.4.0
       Using rails_serve_static_assets 0.0.4
       Using rails_stdout_logging 0.0.4
       Using redcarpet 3.3.4
       Using ref 2.0.0
       Using ruby-ole 1.2.11.8
       Using tilt 2.0.1
       Using wicked_pdf 1.0.6
       Using wkhtmltopdf-binary 0.9.9.3
       Using zip 2.0.2
       Using rdoc 4.2.0
       Using i18n-js 3.0.0.rc12
       Using tzinfo 1.2.2
       Using treetop 1.4.15
       Using rack-test 0.6.3
       Using sprockets 3.4.0
       Using warden 1.2.3
       Using foreman 0.82.0
       Using autoprefixer-rails 6.0.3
       Using uglifier 2.7.2
       Using nokogiri 1.6.6.2
       Using autoparse 0.3.3
       Using launchy 2.4.3
       Using timers 4.0.4
       Using coffee-script 2.4.1
       Using faraday 0.9.2
       Using rb-inotify 0.9.7
       Using logging 2.0.0
       Using unf 0.1.4
       Using rails_12factor 0.0.3
       Using therubyracer 0.12.2
       Using spreadsheet 1.0.8
       Using activesupport 4.1.5
       Using mail 2.5.4
       Using sdoc 0.4.1
       Using bootstrap-sass 3.3.5.1
       Using aws-sdk-v1 1.66.0
       Using axlsx 1.3.6
       Using roo 2.1.1
       Using celluloid 0.16.0
       Using signet 0.6.1
       Using oauth2 1.0.0
       Using domain_name 0.5.25
       Using actionview 4.1.5
       Using activemodel 4.1.5
       Using climate_control 0.0.3
       Using clockwork 2.0.0
       Using delayed_job 4.1.2
       Using jbuilder 2.3.2
       Using roo-xls 1.0.0
       Using aws-sdk 1.66.0
       Using listen 2.10.1
       Using googleauth 0.4.2
       Using http-cookie 1.0.2
       Using cocaine 0.5.7
       Using activerecord 4.1.5
       Using rails-observers 0.1.2
       Using actionpack 4.1.5
       Using mailman 0.7.3
       Using rest-client 1.8.0
       Using paperclip 4.3.1
       Using acts-as-taggable-on 3.5.0
       Using delayed_job_active_record 4.1.1
       Using seed_dump 3.2.2
       Using audited 4.0.0
       Using google-api-client 0.8.6
       Using actionmailer 4.1.5
       Using railties 4.1.5
       Using sprockets-rails 2.3.3
       Using simple_form 3.2.0
       Using audited-activerecord 4.0.0
       Using google_drive 1.0.2
       Using best_in_place 3.0.3
       Using bootstrap-generators 3.3.4
       Using coffee-rails 4.1.0
       Using responders 1.1.2
       Using font-awesome-rails 4.4.0.0
       Using jquery-rails 3.1.4
       Using jquery-ui-rails 5.0.5
       Using rails-i18n 4.0.6
       Using rails 4.1.5
       Using sass-rails 5.0.4
       Using roo-google 1.0.0
       Using devise 3.5.2
       Using acts_as_tenant 0.3.9
       Using rails-console-tweaks 1.0.2
       Using twitter-bootstrap-rails 3.2.0
       Bundle complete! 46 Gemfile dependencies, 129 gems now installed.
       Gems in the groups development and test were not installed.
       Bundled gems are installed into ./vendor/bundle.
       Bundle completed (1.49s)
       Cleaning up the bundler cache.
       Warning: the running version of Bundler is older than the version that created the lockfile. We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
       Detected manifest file, assuming assets were compiled locally

---
       addons:
       - heroku-postgresql
       config_vars:
       LANG: en_US.UTF-8
       RAILS_ENV: production
       RACK_ENV: production
       SECRET_KEY_BASE: my secret key base was here
       default_process_types:
       rake: bundle exec rake
       console: bin/rails console
       web: bin/rails server -p $PORT -e $RAILS_ENV
       worker: bundle exec rake jobs:work
-----> Discovering process types
       Procfile declares types -> web
-----> Releasing mywebapp (dokku/mywebapp:latest)...
-----> Deploying mywebapp (dokku/mywebapp:latest)...
-----> Attempting to run scripts.dokku.predeploy from app.json (if defined)
-----> App Procfile file found (/home/dokku/mywebapp/DOKKU_PROCFILE)
-----> DOKKU_SCALE file found (/home/dokku/mywebapp/DOKKU_SCALE)
=====> web=1
=====> web=1
=====> clock=0
-----> Attempting pre-flight checks
-----> Attempt 1/6 Waiting for 8 seconds ...
       CHECKS expected result:
       http://localhost/check_deploy.txt => "deploy_successful"
 !     
curl: (7) Failed to connect to 172.17.0.3 port 5000: Connection refused
 !     Check attempt 1/6 failed.
-----> Attempt 2/6 Waiting for 8 seconds ...
       CHECKS expected result:
       http://localhost/check_deploy.txt => "deploy_successful"
 !     
curl: (7) Failed to connect to 172.17.0.3 port 5000: Connection refused
 !     Check attempt 2/6 failed.
-----> Attempt 3/6 Waiting for 8 seconds ...
       CHECKS expected result:
       http://localhost/check_deploy.txt => "deploy_successful"
 !     
curl: (7) Failed to connect to 172.17.0.3 port 5000: Connection refused
 !     Check attempt 3/6 failed.
-----> Attempt 4/6 Waiting for 8 seconds ...
       CHECKS expected result:
       http://localhost/check_deploy.txt => "deploy_successful"
 !     
curl: (7) Failed to connect to 172.17.0.3 port 5000: No route to host
 !     Check attempt 4/6 failed.
-----> Attempt 5/6 Waiting for 8 seconds ...
       CHECKS expected result:
       http://localhost/check_deploy.txt => "deploy_successful"
 !     
curl: (7) Failed to connect to 172.17.0.3 port 5000: No route to host
 !     Check attempt 5/6 failed.
-----> Attempt 6/6 Waiting for 8 seconds ...
       CHECKS expected result:
       http://localhost/check_deploy.txt => "deploy_successful"
remote: Could not start due to 1 failed checks.
 !     
curl: (7) Failed to connect to 172.17.0.3 port 5000: No route to host
 !     Check attempt 6/6 failed.
=====> mywebapp web container output:
       05:41:27 web.1     | started with pid 174
       05:41:27 worker.1  | started with pid 175
       05:41:27 clock.1   | started with pid 177
       05:41:27 mailman.1 | started with pid 178
       05:41:32 web.1     | [174] Puma starting in cluster mode...
       05:41:32 web.1     | [174] * Version 3.4.0 (ruby 2.1.2-p95), codename: Owl Bowl Brawl
       05:41:32 web.1     | [174] * Min threads: 5, max threads: 5
       05:41:32 web.1     | [174] * Environment: production
       05:41:32 web.1     | [174] * Process workers: 2
       05:41:32 web.1     | [174] * Preloading application
       05:41:49 worker.1  | [Worker(host:940fe225b794 pid:175)] Starting job worker
       05:41:50 mailman.1 | I, [2017-02-04T05:41:50.728190 #178]  INFO -- : Mailman v0.7.3 started
       05:41:50 mailman.1 | D, [2017-02-04T05:41:50.728960 #178] DEBUG -- : Processing message from STDIN.
       05:41:50 mailman.1 | I, [2017-02-04T05:41:50.730121 #178]  INFO -- : Got new message from 'unknown' with subject ''.
       05:41:51 clock.1   | I, [2017-02-04T05:41:51.649306 #177]  INFO -- : Starting clock for 1 events: [ Run my worker daily ]
       05:41:51 mailman.1 | exited with code 0
       05:41:51 system    | sending SIGTERM to all processes
       05:41:51 worker.1  | [Worker(host:940fe225b794 pid:175)] Exiting...
       05:41:51 worker.1  | rake aborted!
       05:41:51 worker.1  | SignalException: SIGTERM
       05:41:51 worker.1  | /app/vendor/bundle/ruby/2.1.0/gems/delayed_job-4.1.2/lib/delayed/worker.rb:160:in `block in start'
       05:41:51 worker.1  | /app/vendor/bundle/ruby/2.1.0/gems/delayed_job-4.1.2/lib/delayed/worker.rb:186:in `call'
       05:41:51 worker.1  | /app/vendor/bundle/ruby/2.1.0/gems/delayed_job-4.1.2/lib/delayed/worker.rb:186:in `sleep'
       05:41:51 worker.1  | /app/vendor/bundle/ruby/2.1.0/gems/delayed_job-4.1.2/lib/delayed/worker.rb:186:in `block (2 levels) in start'
       05:41:51 worker.1  | /app/vendor/bundle/ruby/2.1.0/gems/delayed_job-4.1.2/lib/delayed/worker.rb:172:in `loop'
       05:41:51 worker.1  | /app/vendor/bundle/ruby/2.1.0/gems/delayed_job-4.1.2/lib/delayed/worker.rb:172:in `block in start'
       05:41:51 worker.1  | /app/vendor/bundle/ruby/2.1.0/gems/delayed_job-4.1.2/lib/delayed/plugins/clear_locks.rb:7:in `call'
       05:41:51 worker.1  | /app/vendor/bundle/ruby/2.1.0/gems/delayed_job-4.1.2/lib/delayed/plugins/clear_locks.rb:7:in `block (2 levels) in <class:ClearLocks>'
       05:41:51 worker.1  | /app/vendor/bundle/ruby/2.1.0/gems/delayed_job-4.1.2/lib/delayed/lifecycle.rb:79:in `call'
       05:41:51 worker.1  | /app/vendor/bundle/ruby/2.1.0/gems/delayed_job-4.1.2/lib/delayed/lifecycle.rb:79:in `block (2 levels) in add'
       05:41:51 worker.1  | /app/vendor/bundle/ruby/2.1.0/gems/delayed_job-4.1.2/lib/delayed/lifecycle.rb:61:in `call'
       05:41:51 worker.1  | /app/vendor/bundle/ruby/2.1.0/gems/delayed_job-4.1.2/lib/delayed/lifecycle.rb:61:in `block in initialize'
       05:41:51 worker.1  | /app/vendor/bundle/ruby/2.1.0/gems/delayed_job-4.1.2/lib/delayed/lifecycle.rb:79:in `call'
       05:41:51 worker.1  | /app/vendor/bundle/ruby/2.1.0/gems/delayed_job-4.1.2/lib/delayed/lifecycle.rb:79:in `block in add'
       05:41:51 worker.1  | /app/vendor/bundle/ruby/2.1.0/gems/delayed_job-4.1.2/lib/delayed/lifecycle.rb:66:in `call'
       05:41:51 worker.1  | /app/vendor/bundle/ruby/2.1.0/gems/delayed_job-4.1.2/lib/delayed/lifecycle.rb:66:in `execute'
       05:41:51 worker.1  | /app/vendor/bundle/ruby/2.1.0/gems/delayed_job-4.1.2/lib/delayed/lifecycle.rb:40:in `run_callbacks'
       05:41:51 worker.1  | /app/vendor/bundle/ruby/2.1.0/gems/delayed_job-4.1.2/lib/delayed/worker.rb:171:in `start'
       05:41:51 worker.1  | /app/vendor/bundle/ruby/2.1.0/gems/delayed_job-4.1.2/lib/delayed/tasks.rb:9:in `block (2 levels) in <top (required)>'
       05:41:51 worker.1  | Tasks: TOP => jobs:work
       05:41:51 worker.1  | (See full trace by running task with --trace)
       05:41:51 worker.1  | exited with code 1
       05:41:52 clock.1   | terminated by SIGTERM
       05:41:52 web.1     | [174] * Listening on tcp://0.0.0.0:5000
       05:41:52 web.1     | [174] Use Ctrl-C to stop
       05:41:52 web.1     | [174] - Gracefully shutting down workers...
       05:41:52 web.1     | [174] === puma shutdown: 2017-02-04 05:41:52 +0000 ===
       05:41:52 web.1     | [174] - Goodbye!
       05:41:52 web.1     | exited with code 0
=====> end mywebapp web container output
To XXX.XXX.XXX.XXX:mywebapp
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'dokku@XXX.XXX.XXX.XXX:mywebapp'

如果有人可以指导我可能出错或遗失的内容,我将非常感激。

1 个答案:

答案 0 :(得分:1)

您的应用应该监听所有接口 - 0.0.0.0 - 而不仅仅是127.0.0.1