Connecting to database specified by DATABASE_URL heroku crash - ruby-on-rails

I keep getting this in the heroku log:
14-10-30T12:59:51+00:00 heroku[slug-compiler]: Slug compilation finished
2014-10-30T12:59:51.608050+00:00 heroku[web.1]: State changed from crashed to starting
2014-10-30T13:00:00.705131+00:00 heroku[web.1]: Starting process with command `bundle exec unicorn -p 35211 -c ./co
nfig/unicorn.rb`
2014-10-30T13:00:03.661476+00:00 app[web.1]: I, [2014-10-30T13:00:03.661285 #2] INFO -- : Refreshing Gem list
2014-10-30T13:00:15.728226+00:00 app[web.1]: Connecting to database specified by DATABASE_URL
2014-10-30T13:00:21.655877+00:00 heroku[web.1]: State changed from starting to crashed
checked pretty much everything all answers in google.
db:setup worked
db:migrate worked
config.assets.initialize_on_precompile = false is set
it's not only heroku, I also get the same error in local production environment:
Macs-MacBook-Pro:v1 mac$ RAILS_ENV=production rails s
=> Booting WEBrick
=> Rails 3.2.13 application starting in production on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Connecting to database specified by database.yml
Exiting
here is database.yml
production:
adapter: postgresql
host: 127.0.0.1
port: 5432
encoding: unicode
database: s1_development
pool: 5
username: postgres
password: password
don't have any problems with local dev environment :(
WHat else can I do ? or how to find the problem ?

Related

My Heroku app using Rails and Postgres suddenly stops working

The error message when I tried to start my app 'lvmine.herokuapp.com':
Application error
An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command
heroku logs --tail
$ heroku logs --tail -a lvmine
We got
2022-02-06T05:34:41.193073+00:00 heroku[web.1]: State changed from crashed to starting
2022-02-06T05:34:43.080374+00:00 heroku[web.1]: Starting process with command `bundle exec rails server -p 17601`
2022-02-06T05:34:45.446271+00:00 app[web.1]: => Booting WEBrick
2022-02-06T05:34:45.446285+00:00 app[web.1]: => Rails 3.2.19 application starting in production on http://0.0.0.0:17601
2022-02-06T05:34:45.446285+00:00 app[web.1]: => Call with -d to detach
2022-02-06T05:34:45.446285+00:00 app[web.1]: => Ctrl-C to shutdown server
2022-02-06T05:34:45.446286+00:00 app[web.1]: Connecting to database specified by DATABASE_URL
2022-02-06T05:34:46.018783+00:00 app[web.1]: Exiting
2022-02-06T05:34:46.019530+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.19/lib/active_record/connection_adapters/postgresql_adapter.rb:1222:in `initialize': SSL error: tlsv1 alert protocol version (PG::ConnectionBad)
2022-02-06T05:34:46.019531+00:00 app[web.1]: FATAL: no pg_hba.conf entry for host "44.200.80.186", user "sajwovtzpjymwu", database "d14n914sh0nmn", SSL off
Seems like SSL problem and Postgres error? I have no clues.
Can anyone help?

action cable subscribing locally, but not on heroku

I've been trying everything I can find online, and nothing is working. Hoping some fresh eyes will see the issue. This is my first time using ActionCable, and everything works great locally, but when pushing to heroku. my logs do not show any actioncable subscriptions like my dev server:
[ActionCable] [email#email.com] MsgsChannel is streaming from msg_channel_34
and when sending a message, I do see [ActionCable] Broadcasting to msg_channel_34: but they are not appending, which I'm guessing means that the received method is not being accessed/called?
I do notice on heroku's logs it says Listening on tcp://0.0.0.0:5000 where as dev it is listening at localhost:3000. Should I be pointnig towards my heroku app somehow?
Here are the relevant configuration files:
Procfile:
web: bundle exec puma -p 5000 ./config.ru
actioncable: bundle exec puma -p 28080 cable/config.ru
redis: redis-server
***Thanks to the comment below, I am also trying. Still not working, but I can see that the port it's listening to is changing, making me believe it has something to do with the configuration? :
web: bundle exec puma -p $PORT ./config.ru
actioncable: bundle exec puma -p $PORT cable/config.ru
redis: redis-server
/cable/config.ru
require ::File.expand_path('../../config/environment', __FILE__)
Rails.application.eager_load!
ActionCable.server.config.allowed_request_origins = ["http://localhost:3000"]
run ActionCable.server
config/environments/development.rb
config.action_cable.allowed_request_origins = ['localhost:3000']
config.action_cable.url = "ws://localhost:3000/cable"
config/environments/production.rb
config.web_socket_server_url = "wss://app-name.herokuapp.com/cable"
config.action_cable.allowed_request_origins = ['https://app-name.herokuapp.com', 'http://app-name.herokuapp.com']
config/cable.yml
local: &local
adapter: async
:url: redis://localhost:6379
:host: localhost
:port: 6379
:timeout: 1
:inline: true
development: *local
test: *local
production:
:url: redis:<%= ENV["REDISTOGO_URL"] %>
adapter: redis
<%= ENV["REDISTOGO_URL"] %> is set, confirmed by running heroku config
routes.rb
mount ActionCable.server => '/cable'
Why is this working on dev, but not on heroku? I've been reading for hours, but can not figure it out. Thank you!!
UPDATE:
heroku logs:
2017-01-25T20:32:57.329656+00:00 heroku[web.1]: Starting process with command `bundle exec puma -p 5000 ./config.ru`
2017-01-25T20:32:59.600554+00:00 app[web.1]: Puma starting in single mode...
2017-01-25T20:32:59.600574+00:00 app[web.1]: * Version 3.6.2 (ruby 2.3.1-p112), codename: Sleepy Sunday Serenity
2017-01-25T20:32:59.600575+00:00 app[web.1]: * Min threads: 0, max threads: 16
2017-01-25T20:32:59.600577+00:00 app[web.1]: * Environment: production
2017-01-25T20:33:02.375128+00:00 app[web.1]: profile controller
2017-01-25T20:33:02.588653+00:00 app[web.1]: Use Ctrl-C to stop
2017-01-25T20:33:02.588446+00:00 app[web.1]: * Listening on tcp://0.0.0.0:5000
2017-01-25T20:33:17.681469+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2017-01-25T20:33:17.681469+00:00 heroku[web.1]: Stopping process with SIGKILL
2017-01-25T20:33:17.862118+00:00 heroku[web.1]: Process exited with status 137
2017-01-25T20:33:57.501746+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2017-01-25T20:33:57.501908+00:00 heroku[web.1]: Stopping process with SIGKILL
2017-01-25T20:33:57.630071+00:00 heroku[web.1]: Process exited with status 137
2017-01-25T20:33:57.642753+00:00 heroku[web.1]: State changed from starting to crashed
The issue was my host is the heroku app, but the requests were coming from the custom domain.
To solve:
heroku config:set RAILS_HOST "http://www.example.com"
And then in production.rb:
config.action_cable.url = "wss://#{ENV['RAILS_HOST']}/cable"
Is your app name literally app-name? I suspect not. Odds are pretty good that these values...
config.web_socket_server_url = "wss://app-name.herokuapp.com/cable"
config.action_cable.allowed_request_origins = ['https://app-name.herokuapp.com', 'http://app-name.herokuapp.com']
Need to be updated to use the actual public-facing URL you intend to connect to.
Your procfile suggests that you run puma with cable/cable.ru on port 28080. Also - file cable/config.ru shouldn't contain this line:
ActionCable.server.config.allowed_request_origins = ["http://localhost:3000"]
You already configured this in config/environment/*.rb
I had the same issue, and found the answer I needed here: redis gem 4+ incompatibility "Specified 'redis' for Action Cable pubsub adapter, but the gem is not loaded". Once I downgraded my redis to 3.1.0, worked perfectly.

getting syntax error while running rails s -e production

After running:
bundle exec rake assets:precompile RAILS_ENV="production"
I run rails s -e production but I am getting following error and server is not starting.
rails s -e production
=> Booting WEBrick
=> Rails 4.2.4 application starting in production on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server Exiting
C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/activesupport4.2.4/lib/active_support/dependencies.rb:274:in `require':
C:/Users/app/models/~$Meeting.rb:1: Invalid char `\x03' in expression (SyntaxError)> from
C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-
4.2.4/lib/active_support/dependencies.rb:274:in `block in require'from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-
4.2.4/lib/active_support/dependencies.rb:240:in `load_dependency'
But running the application on development is working fine.

Error Rails 4 console on staging or production

Join in my office the following command:
RAILS_ENV=production rails s production
And I get the following error:
/usr/local/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/handler.rb:78:in `require': cannot load such file -- rack/handler/production (LoadError)
Please, help!!
Run this command to run the rails server in production mode
rails s -e production
guessing:
RAILS_ENV=production rails s production
to:
RAILS_ENV=production rails s
Sure this is the problem of your command
RAILS_ENV=production rails s production
change it to:
RAILS_ENV=production rails s
usage of rails s command is :
Usage: rails server [mongrel, thin, etc] [options]
-p, --port=port Runs Rails on the specified port.
Default: 3000
-b, --binding=ip Binds Rails to the specified ip.
Default: 0.0.0.0
-c, --config=file Use custom rackup configuration file
-d, --daemon Make server run as a Daemon.
-u, --debugger Enable ruby-debugging for the server.
-e, --environment=name Specifies the environment to run this server under (test/development/production).
Default: development
-P, --pid=pid Specifies the PID file.
Default: tmp/pids/server.pid
-h, --help Show this help message.
so the word following rails s is expected to be server you want to run your application with i.e. (Thin, WEBrick, FastCGI, CGI, SCGI and LiteSpeed.)
rails s thin
=> Booting Thin
=> Rails 3.2.16 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
rails s WEBrick
=> Booting WEBrick
=> Rails 3.2.16 application starting in development on http://0.0.0.0:3000
=> Ctrl-C to shutdown server
It runs as local, and uses WEBrick 1.3.1 I want to run using apache + passenger + rails

How to deploy rails sqlite3 database with capistrano

I am trying deploy like this:
bundle exec cap deploy:cold
RAILS_ENV=production rake db:migrate
bundle exec cap deploy:migrate
but all the time shows error in log file:
I, [2014-04-14T14:15:14.853543 #10769] INFO -- : Started GET "/users/sign_up" for
176.192.228.14 at 2014-04-14 14:15:14 -0400
I, [2014-04-14T14:15:14.856055 #10769] INFO -- : Processing by
Devise::RegistrationsController#new as HTML
I, [2014-04-14T14:15:14.857398 #10769] INFO -- : Completed 500 Internal Server Error
in 1ms
F, [2014-04-14T14:15:14.860844 #10769] FATAL -- :
ActiveRecord::StatementInvalid (Could not find table 'users')
but in the current/db folder was created production.sqlite3 .
In the localhost:3000 it works fine.
How can i migrate db for production with capistrano?
I use nginx and unicorn and this is my repo https://github.com/EgorkZe/bh
Better yet, change up your db configuration:
production:
adapter: sqlite3
database: /absolute/path/to/shared/db/production.sqlite3 # instead of db/production.sqlite3
Working with Sqlite in production is very problematic because each time you deploy new version you entiredb is stay on the old release folder, what you can do is when you deploy add this command:
task :copy_sqlite, roles: :app do
run "cp #{current_path}/db/production.sqlite3 #{release_path}/db/"
end
just add this the before rake db:migrate and it will solve your problem.
My strong suggestion move to PostgreSQL/MySQL.

Resources