Mind Dump, Tech And Life Blog
written by Ivan Alenko
published under license Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)copy! share!
posted at 27. Mar '18
last updated at 16. Apr '24

Capistrano emergency debug and strange errors

An article from old myrtana. I guess it can be still useful for those with Capistrano 2.

I had insanely hard time to use Capistrano for the first time. It just didn’t work. I just kept encountering weird errors and after resolving one, another arisen. But you know, when you are angry and frustrated, things won’t work easily. Btw. I love Capistrano! At least version 3….

Start Unicorn by hand

I tuned Unicorn configuration by hand in production environment. Well, production, one server, small project (myrtana), so who cares?. The first command is needed to run some command in the project (all these environment variables).

DEBUG [2f8442f3] Command: cd /home/myrtana_sk/current/ && ( RAILS_ENV= BUNDLE_GEMFILE=/home/myrtana_sk/current/Gemfile RBENV_ROOT=~/.rbenv RBENV_VERSION=2.0.0-p353 ~/.rbenv/bin/rbenv exec bundle exec unicorn -c /home/myrtana_sk/current/config/unicorn/production.rb -E production -D  )
DEBUG [2f8442f3] 	master failed to start, check stderr log for details

That stupid Unicorn doesn’t work!

I don’t really remember what the problem was here. I guess, that unicorn.pid.oldbin was deleted before it could be used. So…frustrating. Luckily, we have Capistrano 3.3 now and capistrano-unicorn-edge which just works.

hrdina@witch:~/webwork/myrtana_sk$ bundle exec cap production unicorn:restart
DEBUG [8cf5188c] Running /usr/bin/env [ ! -d ~/.rbenv/versions/2.0.0-p353 ] on myrtana.sk
DEBUG [8cf5188c] Command: [ ! -d ~/.rbenv/versions/2.0.0-p353 ]
DEBUG [8cf5188c] Finished in 0.650 seconds with exit status 1 (failed).
DEBUG [62dfa40b] Running /usr/bin/env [ -e /home/myrtana_sk/current/tmp/pids/unicorn.pid ] on myrtana.sk
DEBUG [62dfa40b] Command: [ -e /home/myrtana_sk/current/tmp/pids/unicorn.pid ]
DEBUG [62dfa40b] Finished in 0.771 seconds with exit status 0 (successful).
 INFO [f122d9a7] Running /usr/bin/env kill -0 `cat /home/myrtana_sk/current/tmp/pids/unicorn.pid` > /dev/null 2>&1 on myrtana.sk
DEBUG [f122d9a7] Command: kill -0 `cat /home/myrtana_sk/current/tmp/pids/unicorn.pid` > /dev/null 2>&1
 INFO [f122d9a7] Finished in 0.098 seconds with exit status 0 (successful).
DEBUG [bcafd940] Running /usr/bin/env cat /home/myrtana_sk/current/tmp/pids/unicorn.pid on myrtana.sk
DEBUG [bcafd940] Command: cat /home/myrtana_sk/current/tmp/pids/unicorn.pid
DEBUG [bcafd940] 	6014
DEBUG [bcafd940] Finished in 0.103 seconds with exit status 0 (successful).
 INFO [97dc076b] Running /usr/bin/env  kill -s USR2 6014 on myrtana.sk
DEBUG [97dc076b] Command: /usr/bin/env  kill -s USR2 6014
 INFO [97dc076b] Finished in 0.139 seconds with exit status 0 (successful).
 INFO [6aa77a56] Running /usr/bin/env sleep 2 on myrtana.sk
DEBUG [6aa77a56] Command: /usr/bin/env sleep 2
 INFO [6aa77a56] Finished in 2.102 seconds with exit status 0 (successful).
DEBUG [4b6d1dad] Running /usr/bin/env [ -e /home/myrtana_sk/current/tmp/pids/unicorn.pid.oldbin ] on myrtana.sk
DEBUG [4b6d1dad] Command: [ -e /home/myrtana_sk/current/tmp/pids/unicorn.pid.oldbin ]
DEBUG [4b6d1dad] Finished in 0.099 seconds with exit status 0 (successful).
 INFO [1cd4c8e2] Running /usr/bin/env kill -0 `cat /home/myrtana_sk/current/tmp/pids/unicorn.pid.oldbin` > /dev/null 2>&1 on myrtana.sk
DEBUG [1cd4c8e2] Command: kill -0 `cat /home/myrtana_sk/current/tmp/pids/unicorn.pid.oldbin` > /dev/null 2>&1
DEBUG [1cd4c8e2] 	cat: /home/myrtana_sk/current/tmp/pids/unicorn.pid.oldbin
DEBUG [1cd4c8e2] 	: Adresár alebo súbor neexistuje
cap aborted!
kill -0 `cat /home/myrtana_sk/current/tmp/pids/unicorn.pid.oldbin` > /dev/null 2>&1 stdout: Nothing written
kill -0 `cat /home/myrtana_sk/current/tmp/pids/unicorn.pid.oldbin` > /dev/null 2>&1 stderr: Nothing written

Tasks: TOP => unicorn:restart
(See full trace by running task with --trace)

getpwnam failed??

What was the problem? The command was ran on localhost instead of the server, so a user was, naturally, not found. I guess, this was a bug long time ago or my misconfiguration.

How to resolve this? No idea. The old recipe just don’t work and you cannot do anything about it. Update to Capistrano 3.

hrdina@witch:~/webwork/myrtana.sk-couch$ bundle exec cap production unicorn:stop
DEBUG [9d836c38] Running /usr/bin/env [ ! -d ~/.rbenv/versions/2.0.0-p353 ] on myrtana.sk
DEBUG [9d836c38] Command: [ ! -d ~/.rbenv/versions/2.0.0-p353 ]
DEBUG [9d836c38] Finished in 0.665 seconds with exit status 1 (failed).
/home/hrdina/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/unicorn-4.7.0/lib/unicorn/configurator.rb:556:in `getpwnam': can't find user for myrtana_sk (ArgumentError)
	from /home/hrdina/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/unicorn-4.7.0/lib/unicorn/configurator.rb:556:in `user'
	from config/unicorn/production.rb:14:in `reload'
	from /tmp/unicorn.rb20131202-26052-3wj8qr:7:in `instance_eval'
	from /tmp/unicorn.rb20131202-26052-3wj8qr:7:in `reload'
	from /home/hrdina/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/unicorn-4.7.0/lib/unicorn/configurator.rb:75:in `instance_eval'
	from /home/hrdina/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/unicorn-4.7.0/lib/unicorn/configurator.rb:75:in `reload'
	from /home/hrdina/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/unicorn-4.7.0/lib/unicorn/configurator.rb:68:in `initialize'
	from /home/hrdina/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/unicorn-4.7.0/lib/unicorn/http_server.rb:108:in `new'
	from /home/hrdina/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/unicorn-4.7.0/lib/unicorn/http_server.rb:108:in `initialize'
	from /home/hrdina/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/unicorn-4.7.0/bin/unicorn:126:in `new'
	from /home/hrdina/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/unicorn-4.7.0/bin/unicorn:126:in `<top (required)>'
	from /home/hrdina/.rbenv/versions/2.0.0-p353/bin/unicorn:23:in `load'
	from /home/hrdina/.rbenv/versions/2.0.0-p353/bin/unicorn:23:in `<main>'
DEBUG [33c45fb6] Running /usr/bin/env [ -e /home/myrtana_sk/current/tmp/pids/unicorn.pid ] on myrtana.sk
DEBUG [33c45fb6] Command: [ -e /home/myrtana_sk/current/tmp/pids/unicorn.pid ]
DEBUG [33c45fb6] Finished in 0.685 seconds with exit status 1 (failed).
Unicorn is not running
...
 INFO [bd8d5e88] Finished in 0.101 seconds with exit status 0 (successful).

bundle: command not found

Capistrano won’t install rbenv and won’t install bundler automatically.

Add Comment