boot2docker starting in Windows 7 - docker

I am having issues to start boot2docker in windows 7, virtualbox 4.3.26 (installed together with boot2docker).
Here is the output
Boot2Docker-cli version: v1.6.0
Git commit: 9894ae9
2015/05/05 17:08:12 executing: C:\Program Files\Oracle\VirtualBox\VBoxManage.exe showvminfo boot2docker-vm --machinereadable
2015/05/05 17:08:12 executing: C:\Program Files\Oracle\VirtualBox\VBoxManage.exe guestproperty set boot2docker-vm /VirtualBox/GuestAdd/SharedFolders/MountPrefix /
2015/05/05 17:08:12 executing: C:\Program Files\Oracle\VirtualBox\VBoxManage.exe guestproperty set boot2docker-vm /VirtualBox/GuestAdd/SharedFolders/MountDir /
2015/05/05 17:08:12 executing: C:\Program Files\Oracle\VirtualBox\VBoxManage.exe sharedfolder add boot2docker-vm --name c/Users --hostpath C:\Users --automount
VBoxManage.exe: error: Shared folder named 'c/Users' already exists
VBoxManage.exe: error: Details: code VBOX_E_OBJECT_IN_USE (0x80bb000c), component SessionMachine, interface IMachine, callee IUnknown
VBoxManage.exe: error: Context: "CreateSharedFolder(Bstr(name).raw(), Bstr(hostpath).raw(), fWritable, fAutoMount)" at line 1008 of file VBoxManageMisc.cpp
2015/05/05 17:08:12 executing: C:\Program Files\Oracle\VirtualBox\VBoxManage.exe setextradata boot2docker-vm VBoxInternal2/SharedFoldersEnableSymlinksCreate/c/Users 1
2015/05/05 17:08:12 executing: C:\Program Files\Oracle\VirtualBox\VBoxManage.exe startvm boot2docker-vm --type headless
Waiting for VM "boot2docker-vm" to power on...
VM "boot2docker-vm" has been successfully started.
2015/05/05 17:08:16 executing: C:\Program Files\Oracle\VirtualBox\VBoxManage.exe showvminfo boot2docker-vm --machinereadable
Waiting for VM and Docker daemon to start...
.Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connect
ing to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to t
cp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://loc
alhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2
022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (att
empt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0)
.Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connect
ing to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to t
cp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://loc
alhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2
022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (att
empt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0)
.Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connect
ing to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to t
cp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://loc
alhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2
022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (att
empt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0)VM Host-only IP address:
Waiting for Docker daemon to start...
o2015/05/05 17:09:53 executing: C:\Program Files (x86)\Git\bin\ssh.exe ssh -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet -p 2022 -i C:\Users\zencv\.ssh\id_boot2docker docker#localhost grep tcp:// /proc/$(cat /var/run/docker.pid)/cmdline
Then it hangs..
My virtualbox config is as follows (sorry, in german):
I tried different things such as deleting the boot2docker-vm, downloading again and starting again and again.
Also please note that this seems to be different from similar issues like Boot2Docker Start up fails or docker on windows not working -- in those cases, the error message explicitly mentions that the virtualization is disabled, but I do not see any such error in my output. Unfortunately, I work in a very controlled env. and I cannot use any tools that check whether virtualization is enabled or not.

This similar boot2docker issue mentions:
It sounds like you might have a stray boot2docker-vm set up in VirtualBox -- it's probably worth trying to open the VirtualBox GUI to delete that and try:
boot2docker -v init
boot2docker -v up
The complete reinstall process is:
docker cask remove virtualbox
docker cask install virtualbox
boot2docker delete
boot2docker init
boot2docker up
Also check if you have a %HOME% environment variable defined:
The problem was my SSH Config. When it try to connect to boot2docker vm, it use my github private key and not the boot2docker private key.
I confirm it works perfectly. Just changing %HOME%/.ssh/config
I added:
Host boot2docker
Hostname localhost
IdentityFile ~/.ssh/id_boot2docker

Related

How can I turn off unnecessary command logs in Rails app?

I started to learn Ruby on Rails and I am facing a problem with command logs.
I am starting my server with Command Prompt.
My Ruby version is: 2.7
My Rails version is: 7.0
I want to turn off or hide unnecessary logs.
Logs example:
Post Load (0.5ms) SELECT "posts".* FROM "posts" WHERE "posts"."author_id" = $1 ORDER BY "posts"."created_at" DESC LIMIT $2 [["author_id", 3], ["LIMIT", 3]]
Could not log "sql.active_record" event. Encoding::CompatibilityError: incompatible encoding regexp match (ASCII-8BIT regexp with UTF-8 string) [
"C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activesupport-7.0.4/lib/active_support/backtrace_cleaner.rb:96:in `sub'",
"C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activesupport-7.0.4/lib/active_support/backtrace_cleaner.rb:96:in `block in add_gem_filter'",
"C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activesupport-7.0.4/lib/active_support/backtrace_cleaner.rb:109:in `block (2 levels) in filter_backtrace'",
"C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activerecord-7.0.4/lib/active_record/log_subscriber.rb:144:in `each'",
"C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activerecord-7.0.4/lib/active_record/log_subscriber.rb:144:in `each'",
"C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activerecord-7.0.4/lib/active_record/log_subscriber.rb:144:in `each'",
"C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activerecord-7.0.4/lib/active_record/log_subscriber.rb:144:in `each'",
"C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activerecord-7.0.4/lib/active_record/log_subscriber.rb:144:in `first'",
"C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activerecord-7.0.4/lib/active_record/log_subscriber.rb:144:in `extract_query_source_location'",
"C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activerecord-7.0.4/lib/active_record/log_subscriber.rb:136:in `log_query_source'",
"C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activerecord-7.0.4/lib/active_record/log_subscriber.rb:131:in `debug'",
"C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activerecord-7.0.4/lib/active_record/log_subscriber.rb:71:in `sql'",
"C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activesupport-
I tried to find solution online, but I didn't find anything that will help me.

Create QRCode to be opened URL in browser

In my application I need to show a QRCode that embeds a URL to be opened in a browser.
I'm using the Nayuki library in my Qt/C++ application and I encode this string:
"http://mydevice.local"
but my device (Android) decodes it as a literal string, asking me if I want to copy the text.
Encoding a commercial website, say:
"http://www.google.com"
instead works as expected, asking me if I want to open the URL in a browser.
Because the protocol is not enough to trigger this feature, how I need to encode such a URL?
If http://www.google.com works, but http://mydevice.local doesn't, then it's probably not an encoding problem. Maybe the library that decodes qr codes on your device simply doesn't recognize .local as a valid TLD.
I don't have an android device on hand, but an iphone running IOS 15.1 opens a browser with the desired url for both urls.
for reference, here are the qr codes I used (generated using qrencode -t ansiutf8):
http://mydevice.local:
█████████████████████████████████
█████████████████████████████████
████ ▄▄▄▄▄ █▄▄▄ ▀█▄███ ▄▄▄▄▄ ████
████ █ █ ██▄▀ █ ▄ ▀█ █ █ ████
████ █▄▄▄█ ██▀▄ ▄▀▄█ █ █▄▄▄█ ████
████▄▄▄▄▄▄▄█ ▀▄█ ▀▄▀ █▄▄▄▄▄▄▄████
████▄ █ ▄█▄▀▀▄▀█▄█ ▀ █▄▀▀▀▀▀▄████
████▄▀▀▄ ▄▄▀▄██▄█ ▄▄▀ ▄ ▀▀ ████
████ ██ ▀▄█▀▄ █▀█▀ █▄█▀██▀▄████
████ ▄ ▄█▀▄ ▄█▀▄ ▀ ▀█▄ ▄ ████
████▄██▄█▄▄█▀▄▄ ▄▀▄▄ ▄▄▄ █▄ █████
████ ▄▄▄▄▄ ███▄▀▄▀ ▀ █▄█ ▄██▄████
████ █ █ █ ▀▀▄▀ ▀ ▄▄ █ ████
████ █▄▄▄█ █▀ ▄ ▀ █▄▄█▀ █ ████
████▄▄▄▄▄▄▄█▄▄▄▄▄▄██▄▄███▄██▄████
█████████████████████████████████
█████████████████████████████████
http://www.google.com:
█████████████████████████████████
█████████████████████████████████
████ ▄▄▄▄▄ █▄▄▄ ▀█▄█ █ ▄▄▄▄▄ ████
████ █ █ ██▄▀ █ █▄▀█ █ █ ████
████ █▄▄▄█ ██▀▄ ▄▀▄█ █ █▄▄▄█ ████
████▄▄▄▄▄▄▄█ ▀▄█ ▀▄█ █▄▄▄▄▄▄▄████
████ █ █▄██▄▀█▄▀ ▀▄▀▄▀▀▀▀▀▄████
████ ▀▄█▄▄▄▀▄▄██▄▄▀ ▄█▄ █ ▀▀ ████
████ █▀█▄▄▄▀█ █▀█▀ ▄▄█▀██▀▄████
████ ▄ ▀█▀▄▄▄ █▀▄▄ █▄█▀ ▄ ▄ ████
████▄███▄▄▄█▀ ▀ ▄▀▄█ ▄▄▄ █▄ █████
████ ▄▄▄▄▄ ██ ▀▀▄▀ ▀ █▄█ ▄██▄████
████ █ █ █ ▄█▄▀ ▀ ▄ ▄ █ ████
████ █▄▄▄█ █▀▄▄ ▀ ██▄▄▀ █ ████
████▄▄▄▄▄▄▄█▄█▄▄▄▄██▄████▄██▄████
█████████████████████████████████
█████████████████████████████████

redirect_to is undefined

I'm trying to use a redirect_to in my controller and I'm getting an error complaining that redirect_to is not defined (please see logs below)
=> Booting Puma
=> Rails 5.2.1 application starting in development
=> Run rails server -h for more startup options Puma starting in single mode...
* Version 3.12.0 (ruby 2.5.1-p57), codename: Llamas in Pajamas
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop Started GET "/checkout" for 127.0.0.1 at 2018-11-22 13:18:56 -0800 (0.1ms)
SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY
"schema_migrations"."version" ASC ↳
/var/lib/gems/2.5.0/gems/activerecord-5.2.1/lib/active_record/log_subscriber.rb:98
ActionController::RoutingError (undefined method `redirect_to' for
ChargesController:Class):
app/controllers/charges_controller.rb:39:in
`<class:ChargesController>' app/controllers/charges_controller.rb:3:in
`<main>'
My code is below. I'm not sure what I'm doing wrong. How do I go about debugging this? Any help would be appreciated.
class ChargesController < ApplicationController
def create
redirect_to(:controller => 'home_controller', :action => "index")
end
In my rails routes.rb I have
get "/charge", to: "charges#create"

PG::ConnectionBad: could not connect to server: after deploying rails app using passenger, nginx and capistrano

After a resent deploy of a Railsapplication to a Ubuntu 16.04.1 x64 VPS the server is not able to start. Since yesterday I've been trying to solve why, but without any luck. Now I'm totally helpless and out of options.
The deploy stops at:
deploy:migrating
01 $HOME/.rbenv/bin/rbenv exec bundle exec rake db:migrate
01 rake aborted!
01 PG::ConnectionBad: could not connect to server: Connection refused
01 Is the server running on host "127.0.0.1" and accepting
01 TCP/IP connections on port 5432?
Because of this error messages I've changed the settings in the pg_hba.conf and the postgresql.conf to the following examples according to this article http://www.railszilla.com/postgresql-tcpip-connections-port-5432/coffee-break
`pg_hba.conf`
# Database administrative login by Unix domain socket
local all postgres peer
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all md5
# IPv4 local connections:
host all all 0.0.0.0/0 trust
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication postgres peer
#host replication postgres 127.0.0.1/32 md5
#host replication postgres ::1/128 md5
And the postgresql.conf settings (See below).
# - Connection Settings -
listen_addresses = '*' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost'; use '*' for all
# (change requires restart)
port = 5432 # (change requires restart)
max_connections = 100 # (change requires restart)
#superuser_reserved_connections = 3 # (change requires restart)
unix_socket_directories = '/var/run/postgresql' # comma-separated list of
directories
# (change requires restart)
#unix_socket_group = '' # (change requires restart)
#unix_socket_permissions = 0777 # begin with 0 to use octal notation
# (change requires restart)
#bonjour = off # advertise server via Bonjour
# (change requires restart)
#bonjour_name = '' # defaults to the computer name
# (change requires restart)
# - Security and Authentication -
And after restarting by sudo service postgresql restart I still get the same error after deploying again.
Update, database.yml from server
Here is the database.yml from the server.
production:
adapter: postgresql
host: 127.0.0.1
database: databasename
username: username
password: password
encoding: unicode
pool: 5
In the /var/log/nginx/error.log the last line is like this [ 2017-09-27 13:09:13.4321 1530/7fa87d58e700 age/Cor/Con/CheckoutSession.cpp:285 ]: [Client 1-149] Cannot checkout session because a spawning error occurred. The identifier of the error is c620ca8b. Please see earlier logs for details about the error.
As it says I checked out earlier logs. Below is the whole log. It is reffering to a order_notifier.rb witch is supposed to have a bad syntax.
here is the whole log for the error c620ca8b :
[ 2017-09-27 13:02:37.1572 1530/7fa87d58e700 age/Cor/Con/CheckoutSession.cpp:285 ]: [Client 1-148] Cannot checkout session because a spawning error occurred. The identifier of the error is 446bb8e9. Please see earlier logs for details about the error.
App 20925 stdout:
App 20925 stdout:
[ 2017-09-27 13:09:13.4236 1530/7fa88401a700 age/Cor/App/Implementation.cpp:304 ]: Could not spawn process for application /home/deploy/hlinreykdal/current: An error occurred while starting up the preloader.
Error ID: c620ca8b
Error details saved to: /tmp/passenger-error-Mirupe.html
Message from application: /home/deploy/hlinreykdal/releases/20170926133751/app/mailers/order_notifier.rb:8: syntax error, unexpected tLABEL
mail (to: order.email, subject: 'Hlin Reykdal Concept Store',
^
/home/deploy/hlinreykdal/releases/20170926133751/app/mailers/order_notifier.rb:8: syntax error, unexpected tLABEL, expecting '='
mail (to: order.email, subject: 'Hlin Reykdal Concept Store',
^
/home/deploy/hlinreykdal/releases/20170926133751/app/mailers/order_notifier.rb:8: syntax error, unexpected ',', expecting keyword_end
mail (to: order.email, subject: 'Hlin Reykdal Concept Store',
^
/home/deploy/hlinreykdal/releases/20170926133751/app/mailers/order_notifier.rb:12: syntax error, unexpected ')', expecting keyword_end
/home/deploy/hlinreykdal/releases/20170926133751/app/mailers/order_notifier.rb:21: syntax error, unexpected tLABEL
mail (to: order.email, subject: 'Order Shipped')
^
/home/deploy/hlinreykdal/releases/20170926133751/app/mailers/order_notifier.rb:21: syntax error, unexpected tLABEL, expecting '='
mail (to: order.email, subject: 'Order Shipped')
^
/home/deploy/hlinreykdal/releases/20170926133751/app/mailers/order_notifier.rb:21: syntax error, unexpected ')', expecting keyword_end (SyntaxError)
/home/deploy/hlinreykdal/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:244:in `rescue in load_dependency'
/home/deploy/hlinreykdal/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:237:in `load_dependency'
/home/deploy/hlinreykdal/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:274:in `require'
/home/deploy/hlinreykdal/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:360:in `require_or_load'
/home/deploy/hlinreykdal/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:317:in `depend_on'
/home/deploy/hlinreykdal/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:233:in `require_dependency'
/home/deploy/hlinreykdal/shared/bundle/ruby/2.3.0/gems/railties-4.2.5/lib/rails/engine.rb:472:in `block (2 levels) in eager_load!'
/home/deploy/hlinreykdal/shared/bundle/ruby/2.3.0/gems/railties-4.2.5/lib/rails/engine.rb:471:in `each'
/home/deploy/hlinreykdal/shared/bundle/ruby/2.3.0/gems/railties-4.2.5/lib/rails/engine.rb:471:in `block in eager_load!'
/home/deploy/hlinreykdal/shared/bundle/ruby/2.3.0/gems/railties-4.2.5/lib/rails/engine.rb:469:in `each'
/home/deploy/hlinreykdal/shared/bundle/ruby/2.3.0/gems/railties-4.2.5/lib/rails/engine.rb:469:in `eager_load!'
/home/deploy/hlinreykdal/shared/bundle/ruby/2.3.0/gems/railties-4.2.5/lib/rails/engine.rb:346:in `eager_load!'
/home/deploy/hlinreykdal/shared/bundle/ruby/2.3.0/gems/railties-4.2.5/lib/rails/application/finisher.rb:56:in `each'
/home/deploy/hlinreykdal/shared/bundle/ruby/2.3.0/gems/railties-4.2.5/lib/rails/application/finisher.rb:56:in `block in <module:Finisher>'
And here is the order_notifier.rb I can´t see what is wrong whit it, maybe someone here can.
class OrderNotifier < ApplicationMailer
default from: 'Hlin Reykdal Concept Store <hlin#hlinreykdal.com>'
def received(order)
#order = order
mail (to: order.email, subject: 'Hlin Reykdal Concept Store')
end
def shipped(order)
#order = order
mail (to: order.email, subject: 'Order Shipped')
end
end
I've restarted both the nginx by sudo service nginx restart and the app by bundle exec passenger-config restart-app but with out a luck, still getting the same error if I deploy again.
I googled all over the web and looked at hundreds of posts here on stack. Nothing seems to work. Now I'm getting really desperate about this. I've had similar problems before after a deploy, but I've always managed to fix it, but this seems to be aout of my league.
UPDATE
It seems like the production log is stuck in 23/5 2017 even after all my restarts and deploys. It seems like it is stuck in an error from the mailer??
I, [2017-05-23T11:01:44.741054 #1060] INFO -- : Completed 500 Internal
Server Error in 66ms (ActiveRecord: 4.2ms)
F, [2017-05-23T11:01:44.743481 #1060] FATAL -- :
SocketError (getaddrinfo: Name or service not known):
app/admin/order.rb:6:in `block (2 levels) in <top (required)>'
I, [2017-05-23T11:10:08.863192 #1060] INFO -- : Started GET "/products/41" for 164.132.161.46 at 2017-05-23 11:10:08 +0000
I, [2017-05-23T11:10:08.876373 #1060] INFO -- : Processing by ProductsController#show as */*
I, [2017-05-23T11:10:08.876536 #1060] INFO -- : Parameters: {"id"=>"41"}
D, [2017-05-23T11:10:08.881123 #1060] DEBUG -- : ^[[1m^[[35mCart Load (0.7ms)^[[0m SELECT "carts".* FROM "carts" WHERE "carts"."id" = $1 LIMIT 1 [["id", nil]]
D, [2017-05-23T11:10:08.882685 #1060] DEBUG -- : ^[[1m^[[36m (0.2ms)^[[0m ^[[1mBEGIN^[[0m
D, [2017-05-23T11:10:08.887770 #1060] DEBUG -- : ^[[1m^[[35mSQL (1.3ms)^[[0m INSERT INTO "carts" ("created_at", "updated_at") VALUES ($1, $2) RETURNING "id" [["created_at", "2017-05-23 11:10:08.883411"], ["updated_at", "2017-05-23 11:10:08.883411"]]
D, [2017-05-23T11:10:08.890018 #1060] DEBUG -- : ^[[1m^[[36m (0.7ms)^[[0m ^[[1mCOMMIT^[[0m
D, [2017-05-23T11:10:08.893274 #1060] DEBUG -- : ^[[1m^[[35mProduct Load (1.2ms)^[[0m SELECT "products".* FROM "products" WHERE "products"."slug" = $1 ORDER BY "products"."id" ASC LIMIT 1 [["slug", "41"]]
D, [2017-05-23T11:10:08.894865 #1060] DEBUG -- : ^[[1m^[[36mProduct Load (0.4ms)^[[0m ^[[1mSELECT "products".* FROM "products" WHERE "products"."id" = $1 LIMIT 1^[[0m [["id", 41]]
D, [2017-05-23T11:10:08.900733 #1060] DEBUG -- : ^[[1m^[[35mLabel Load (1.2ms)^[[0m SELECT "labels".* FROM "labels" WHERE "labels"."id" = $1 LIMIT 1 [["id", 8]]
D, [2017-05-23T11:10:08.907954 #1060] DEBUG -- : ^[[1m^[[36mProduct Load (0.6ms)^[[0m ^[[1mSELECT "products".* FROM "products" WHERE "products"."category_id" = $1 ORDER BY RANDOM() LIMIT 6^[[0m [["category_id", 12]]
I, [2017-05-23T11:10:08.916955 #1060] INFO -- : Rendered products/show.html.erb within layouts/application (18.7ms)
D, [2017-05-23T11:10:08.920965 #1060] DEBUG -- : ^[[1m^[[35mCategory Load (0.8ms)^[[0m SELECT "categories".* FROM "categories"
D, [2017-05-23T11:10:08.924524 #1060] DEBUG -- : ^[[1m^[[36mLabel Load (0.3ms)^[[0m ^[[1mSELECT "labels".* FROM "labels"^[[0m
D, [2017-05-23T11:10:08.929926 #1060] DEBUG -- : ^[[1m^[[35m (0.3ms)^[[0m SELECT COUNT(*) FROM "product_items" WHERE "product_items"."cart_id" = $1 [["cart_id", 46319]]
I, [2017-05-23T11:10:08.930159 #1060] INFO -- : Rendered application/_navbar.html.erb (10.7ms)
I, [2017-05-23T11:10:08.931046 #1060] INFO -- : Rendered application/_message.html.erb (0.2ms)
I, [2017-05-23T11:10:08.932261 #1060] INFO -- : Rendered emaillist/_email.html.erb (0.6ms)
I, [2017-05-23T11:10:08.932381 #1060] INFO -- : Rendered application/_notifications.html.erb (0.9ms)
I, [2017-05-23T11:10:08.936424 #1060] INFO -- : Rendered application/_footer.html.erb (3.5ms)
I, [2017-05-23T11:10:08.936826 #1060] INFO -- : Completed 200 OK in 60ms (Views: 36.7ms | ActiveRecord: 7.6ms)
I, [2017-05-23T11:12:35.005157 #1060] INFO -- : Started GET "/labels/10" for 66.249.65.74 at 2017-05-23 11:12:35 +0000
I, [2017-05-23T11:12:35.040137 #1060] INFO -- : Processing by LabelsController#show as HTML
I, [2017-05-23T11:12:35.040544 #1060] INFO -- : Parameters: {"id"=>"10"}
D, [2017-05-23T11:12:35.049755 #1060] DEBUG -- : ^[[1m^[[36mCart Load (0.8ms)^[[0m ^[[1mSELECT "carts".* FROM "carts" WHERE "carts"."id" = $1 LIMIT 1^[[0m [["id", nil]]
D, [2017-05-23T11:12:35.052776 #1060] DEBUG -- : ^[[1m^[[35m (0.2ms)^[[0m BEGIN
D, [2017-05-23T11:12:35.060048 #1060] DEBUG -- : ^[[1m^[[36mSQL (0.9ms)^[[0m ^[[1mINSERT INTO "carts" ("created_at", "updated_at") VALUES ($1, $2) RETURNING "id"^[[0m [["created_at", "2017-05-23 11:12:35.053857"], ["updated_at", "2017-05-23 11:12:35.053857"]]
D, [2017-05-23T11:12:35.061486 #1060] DEBUG -- : ^[[1m^[[35m (0.6ms)^[[0m COMMIT
D, [2017-05-23T11:12:35.065373 #1060] DEBUG -- : ^[[1m^[[36mLabel Load (0.4ms)^[[0m ^[[1mSELECT "labels".* FROM "labels" WHERE "labels"."id" = $1 LIMIT 1^[[0m [["id", 10]]
I, [2017-05-23T11:12:35.067624 #1060] INFO -- : Completed 404 Not Found in 27ms (ActiveRecord: 3.0ms)
F, [2017-05-23T11:12:35.069957 #1060] FATAL -- :
ActiveRecord::RecordNotFound (Couldn't find Label with 'id'=10):
app/controllers/labels_controller.rb:21:in `set_label'
rm /usr/local/var/postgres/postmaster.pid
Restart Postgresql
sudo service postgresql restart
Finally I managed to fix my problem, after following the answer provided here : https://askubuntu.com/questions/810008/after-upgrade-14-04-to-16-04-1-postgresql-server-does-not-start
and then do the modifycations provided here : https://gist.github.com/GabLeRoux/0c60f9be0c28b6b41f64cb55474b0ccb
May app is up and running again...

Resque worker causing ActiveRecord::StatementInvalid: PG::Error: SSL SYSCALL error: EOF detected

I've had this problem on two apps now. Heroku themselves haven't been able to be much help (yet).
I am using:
Rails 3.2.9
Unicorn
Heroku, with a Postgres Dev (free) database and OpenRedis Micro
MongoDB (for storing social network statuses)
Resque
Resque-scheduler
Everything works great when running with my local Postgres and Redis databases.
And here's an example of the the errors in my Heroku log:
2013-01-01T21:17:27+00:00 app[resque_worker.1]: Found job on #<Resque::Queue:0x00000006652920>
2013-01-01T21:17:27+00:00 app[resque_worker.1]: got: (Job{facebook} | FacebookRefresh | ["facebook_key"])
2013-01-01T21:17:27+00:00 app[resque_worker.1]: Running before_fork hooks with [(Job{facebook} | FacebookRefresh | ["facebook_key"])]
2013-01-01T21:17:27+00:00 app[resque_worker.1]: Running after_fork hooks with [(Job{facebook} | FacebookRefresh | ["facebook_key"])]
2013-01-01T21:17:27+00:00 app[resque_worker.1]: resque-2.0.0.pre.1: Processing facebook since 1357075047
2013-01-01T21:17:27+00:00 app[resque_worker.1]: resque-2.0.0.pre.1: Forked 503 at 1357075047
2013-01-01T21:17:27+00:00 app[resque_worker.1]: Running before_perform hooks with [(Job{facebook} | FacebookRefresh | ["facebook_key"])]
2013-01-01T21:17:27+00:00 app[resque_worker.1]: : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
2013-01-01T21:17:27+00:00 app[resque_worker.1]: FROM pg_attribute a LEFT JOIN pg_attrdef d
2013-01-01T21:17:27+00:00 app[resque_worker.1]: ON a.attrelid = d.adrelid AND a.attnum = d.adnum
2013-01-01T21:17:27+00:00 app[resque_worker.1]: pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
2013-01-01T21:17:27+00:00 app[resque_worker.1]: ). Retrying...
2013-01-01T21:17:27+00:00 app[resque_worker.1]: Performing FacebookRefresh caused an exception (PG::Error: SSL SYSCALL error: EOF detected
2013-01-01T21:17:27+00:00 app[resque_worker.1]: WHERE a.attrelid = '"facebook_accounts"'::regclass
2013-01-01T21:17:27+00:00 app[resque_worker.1]: ORDER BY a.attnum
2013-01-01T21:17:27
+00:00 app[resque_worker.1]: AND a.attnum > 0 AND NOT a.attisdropped
2013-01-01T21:17:27+00:00 app[resque_worker.1]: : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
2013-01-01T21:17:27+00:00 app[resque_worker.1]: FROM pg_attribute a LEFT JOIN pg_attrdef d
2013-01-01T21:17:27+00:00 app[resque_worker.1]: ON a.attrelid = d.adrelid AND a.attnum = d.adnum
2013-01-01T21:17:27+00:00 app[resque_worker.1]: (Job{facebook} | FacebookRefresh | ["facebook_key"]) failed: #<ActiveRecord::StatementInvalid: PG::Error: SSL SYSCALL error: EOF detected
2013-01-01T21:17:27+00:00 app[resque_worker.1]: >
2013-01-01T21:17:27+00:00 app[resque_worker.1]: pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
2013-01-01T21:17:27+00:00 app[resque_worker.1]: AND a.attnum > 0 AND NOT a.attisdropped
2013-01-01T21:17:27+00:00 app[resque_worker.1]: WHERE a.attrelid = '"facebook_accounts"'::regclass
2013-01-01T21:17:27+00:00 app[resque_worker.1]: ORDER BY a.attnum
2013-01-01T21:17:27+00:00 app[resque_worker.1]: Running before_fork hooks with [(Job{facebook} | FacebookRefresh | ["facebook_key"])]
I've tried so many before_hook and after_hook things in my unicorn's config file, but none of them seem to help.
# What the timeout for killing busy workers is, in seconds
timeout 60
# Whether the app should be pre-loaded
preload_app true
# How many worker processes
worker_processes 3
before_fork do |server, worker|
# Replace with MongoDB or whatever
if defined?(ActiveRecord::Base)
ActiveRecord::Base.connection.disconnect!
Rails.logger.info('Disconnected from ActiveRecord')
end
# If you are using Redis but not Resque, change this
if defined?(Resque)
Resque.redis.quit
Rails.logger.info('Disconnected from Redis')
end
sleep 1
end
after_fork do |server, worker|
if defined?(ActiveRecord::Base)
ActiveRecord::Base.establish_connection
Rails.logger.info('Connected to ActiveRecord')
end
if defined?(Resque)
Resque.redis = ENV['OPENREDIS_URL'] || 'redis://localhost:6379'
Rails.logger.info('Connected to Redis')
end
end
And my Procfile
web: bundle exec unicorn -c lib/unicorn/config.rb -p $PORT
resque_scheduler: env bundle exec rake resque:scheduler
resque_worker: env QUEUE=* bundle exec rake environment resque:work
So one thing I'm wondering is that my resque_worker doesn't use the Unicorn config at all, and since its running on a completely separate Heroku worker, I'm unsure if there's any way it would know about that stuff. The web instnace is just fine, as is the scheduler. Its just the resque_worker that's blowing up on every postgres call.
I'm not making any particularly crazy database calls from the worker. An example on might be:
def queue_users_for_refresh
FacebookAccount.all.each do |x|
Resque.enqueue(FacebookAccountRefresh, x.username)
end
end
And another one later (in the FacebookAccountRefresh) that is:
FacebookAccount.where(:username => user).first
This looks like an error caused by sharing database connections across processes incorrectly. This happens when the Resque worker isn't re-initializing database connections after forking.
Do you have a Resque initializer? It looks like you're missing after_fork directives for Resque workers to match the ones in your Unicorn app server workers.
Add/edit your Resque initializer file (ie: config/initializers/resque.rb):
Resque.after_fork = Proc.new { ActiveRecord::Base.establish_connection }

Resources