【发布时间】:2017-11-26 23:13:25
【问题描述】:
我在 Heroku 上部署一个简单的 ruby on rails api 时遇到问题。
当我部署我的应用程序(使用 gitlab CI)时,我有 这个日志:
Running with gitlab-runner 10.2.0 (0a75cdd1)
on docker-auto-scale (e11ae361)
Using Docker executor with image ruby:2.1 ...
Using docker image sha256:7015fc5d87110d5a132c5b6c18b20e90eb82411bc185f830f9dd394bc2dadf2a for predefined container...
Pulling docker image ruby:2.1 ...
Using docker image ruby:2.1 ID=sha256:223d1eaa9523fa64e78f5a92b701c9c11cbc507f0ff62246dbbacdae395ffea3 for build container...
Running on runner-e11ae361-project-4748707-concurrent-0 via runner-e11ae361-srm-1511735932-7447f02a...
Cloning repository...
Cloning into '/builds/theodugautier/wsfcontender'...
Checking out 8d295d1d as develop...
Skipping Git submodules setup
$ cd app/
$ gem install bundler
Successfully installed bundler-1.16.0
1 gem installed
$ gem install dpl
Successfully installed dpl-1.8.43
1 gem installed
$ dpl --provider=heroku --app=$APP_NAME_DEV --api-key=$HEROKU_API_KEY
Installing deploy dependencies
Successfully installed rendezvous-0.1.2
1 gem installed
Successfully installed multipart-post-2.0.0
Successfully installed faraday-0.13.1
2 gems installed
authentication succeeded
checking for app wsfcontenders-rails-dev
found app wsfcontenders-rails-dev
Preparing deploy
Cleaning up git repository with `git stash --all`. If you need build artifacts for deployment, set `deploy.skip_cleanup: true`. See https://docs.travis-ci.com/user/deployment/#Uploading-Files.
No local changes to save
creating application archive
Deploying application
uploading application archive
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 21833 0 0 100 21833 0 274k --:--:-- --:--:-- --:--:-- 276k
triggering new deployment
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0
100 54 0 54 0 0 31 0 --:--:-- 0:00:01 --:--:-- 31
100 92 0 92 0 0 33 0 --:--:-- 0:00:02 --:--:-- 33
100 269 0 269 0 0 62 0 --:--:-- 0:00:04 --:--:-- 62
100 334 0 334 0 0 63 0 --:--:-- 0:00:05 --:--:-- 63
100 396 0 396 0 0 69 0 --:--:-- 0:00:05 --:--:-- 87
100 2159 0 2159 0 0 325 0 --:--:-- 0:00:06 --:--:-- 429
100 2318 0 2318 0 0 276 0 --:--:-- 0:00:08 --:--:-- 394
100 2318 0 2318 0 0 247 0 --:--:-- 0:00:09 --:--:-- 406
100 2337 0 2337 0 0 227 0 --:--:-- 0:00:10 --:--:-- 397
100 2357 0 2357 0 0 211 0 --:--:-- 0:00:11 --:--:-- 361
100 2450 0 2450 0 0 209 0 --:--:-- 0:00:11 --:--:-- 57
100 2450 0 2450 0 0 209 0 --:--:-- 0:00:11 --:--:-- 39
-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.2.8
-----> Installing dependencies using bundler 1.15.2
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
Fetching gem metadata from https://rubygems.org/.........
Fetching version metadata from https://rubygems.org/..
Fetching dependency metadata from https://rubygems.org/.
Using rake 12.3.0
Using concurrent-ruby 1.0.5
Using minitest 5.10.3
Using thread_safe 0.3.6
Using builder 3.2.3
Using erubi 1.7.0
Using mini_portile2 2.3.0
Using crass 1.0.3
Using rack 2.0.3
Using nio4r 2.1.0
Using websocket-extensions 0.1.3
Using mini_mime 1.0.0
Using arel 8.0.0
Using bundler 1.15.2
Using method_source 0.9.0
Using pg 0.21.0
Using puma 3.11.0
Using thor 0.20.0
Using i18n 0.9.1
Using tzinfo 1.2.4
Using nokogiri 1.8.1
Using rack-test 0.8.2
Using sprockets 3.7.1
Using websocket-driver 0.6.5
Using mail 2.7.0
Using activesupport 5.1.4
Using loofah 2.1.1
Using rails-dom-testing 2.0.3
Using globalid 0.4.1
Using activemodel 5.1.4
Using rails-html-sanitizer 1.0.3
Using activejob 5.1.4
Using activerecord 5.1.4
Using actionview 5.1.4
Using actionpack 5.1.4
Using actioncable 5.1.4
Using actionmailer 5.1.4
Using railties 5.1.4
Using sprockets-rails 3.2.1
Using rails 5.1.4
Bundle complete! 8 Gemfile dependencies, 40 gems now installed.
Gems in the groups development and test were not installed.
Bundled gems are installed into ./vendor/bundle.
The latest bundler is 1.16.0, but you are currently running 1.15.2.
To update, run `gem install bundler`
Bundle completed (2.57s)
Cleaning up the bundler cache.
The latest bundler is 1.16.0, but you are currently running 1.15.2.
To update, run `gem install bundler`
-----> Detecting rake tasks
-----> Discovering process types
Procfile declares types -> web
Default types for buildpack -> console, rake, worker
-----> Compressing...
Done: 22.3M
-----> Launching...
Released v7
https://my_api_url.com/ deployed to Heroku
No stash found.
Job succeeded
当我使用邮递员(使用邮递员)获取我的 api URL 时,我有这个日志:
2017-11-26T22:42:44.868503+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/characters" host=wsfcontenders-rails-dev.herokuapp.com request_id=1d0860a2-a26f-42e9-90ab-58213e0357a9 fwd="90.44.177.33" dyno= connect= service= status=503 bytes= protocol=https
所以,我尝试重新启动我的应用程序(重新启动所有 Dynos):
2017-11-26T22:42:11.389014+00:00 heroku[web.1]: State changed from crashed to starting
2017-11-26T22:42:15.007314+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 45211 -e production`
2017-11-26T22:42:21.621084+00:00 app[web.1]: A server is already running. Check /app/tmp/pids/server.pid.
2017-11-26T22:42:21.661103+00:00 app[web.1]: => Booting Puma
2017-11-26T22:42:21.661106+00:00 app[web.1]: => Rails 5.1.4 application starting in production
2017-11-26T22:42:21.661106+00:00 app[web.1]: => Run `rails server -h` for more startup options
2017-11-26T22:42:21.661107+00:00 app[web.1]: Exiting
2017-11-26T22:42:21.844594+00:00 heroku[web.1]: State changed from starting to crashed
2017-11-26T22:42:21.806442+00:00 heroku[web.1]: Process exited with status 1
在我的应用中:
我的Procfile:
web: bin/rails server -p 45211 -e production
我的Gemfile:
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.4'
# Use sqlite3 as the database for Active Record
gem 'pg', '~> 0.18'
# Use Puma as the app server
gem 'puma', '~> 3.7'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
# gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
# gem 'rack-cors'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end
group :development do
gem 'listen', '>= 3.0.5', '< 3.2'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
ruby "2.2.8"
有什么想法吗? :)
谢谢!
【问题讨论】:
-
我认为错误是因为您的测功机没有运行,请打开测功机
标签: ruby-on-rails ruby heroku deployment ruby-on-rails-5.1