When requests come to my server at the time of deployment, it got failed. I'm using Ubuntu in AWS EC2. As I'm using Elastic Load Balancer, I have tried my instance to deregister from and again register with Load Balancer so that meanwhile I can start unicorn server. Also before starting unicorn I'm removing unicorn.pid
inst=$(ec2metadata --instance-id)`
aws elb deregister-instances-from-load-balancer --load-balancer-name my_load_balancer_name --instances $inst
echo "Server deregistered from Load Balancer"
sleep 10s
file="/home/ubuntu/pids/unicorn.pid"
if [ -f $file ];
then
echo "File found:"
ls /home/ubuntu/pids/
rm ~/pids/unicorn.pid
echo "unicorn.pid removed"
ls /home/ubuntu/pids/ #cross-checking the removal of the unicorn.pid
echo "if you see \"unicorn.pid removed\" message just above this line, it means unicorn.pid removed successfully"
else
echo "$file not found"
fi
RAILS_ENV=qa bundle exec unicorn -c config/unicorn.rb -D #this command is giving error "[stderr]master failed to start, check stderr log for details" `
Any help is highly appreciated.
stderr logs
I, [2017-02-22T14:44:12.773724 #12531] INFO -- : Refreshing Gem list
E, [2017-02-22T14:44:21.233361 #12531] ERROR -- : adding listener failed addr=/home/ubuntu/unicorn.sock (in use)
E, [2017-02-22T14:44:21.233422 #12531] ERROR -- : retrying in 0.5 seconds (4 tries left)
E, [2017-02-22T14:44:21.733925 #12531] ERROR -- : adding listener failed addr=/home/ubuntu/unicorn.sock (in use) E, [2017-02-22T14:44:21.734008 #12531] ERROR -- : retrying in 0.5 seconds (3 tries left)
E, [2017-02-22T14:44:22.234528 #12531] ERROR -- : adding listener failed addr=/home/ubuntu/unicorn.sock (in use)
E, [2017-02-22T14:44:22.234626 #12531] ERROR -- : retrying in 0.5 seconds (2 tries left)
E, [2017-02-22T14:44:22.735121 #12531] ERROR -- : adding listener failed addr=/home/ubuntu/unicorn.sock (in use)
E, [2017-02-22T14:44:22.738710 #12531] ERROR -- : retrying in 0.5 seconds (1 tries left) E, [2017-02-22T14:44:23.239213 #12531] ERROR -- : adding listener failed addr=/home/ubuntu/unicorn.sock (in use) E, [2017-02-22T14:44:23.239293 #12531] ERROR -- : retrying in 0.5 seconds (0 tries left)
E, [2017-02-22T14:44:23.739818 #12531] ERROR -- : adding listener failed addr=/home/ubuntu/unicorn.sock (in use)
Errno::EADDRINUSE: Address already in use - connect(2) for /home/ubuntu/unicorn.sock"
/home/ubuntu/ZenSol/curr/vendor/bundle/ruby/2.1.0/gems/unicorn-4.9.0/lib/unicorn/socket_helper.rb:158:in `initialize'
/home/ubuntu/ZenSol/curr/vendor/bundle/ruby/2.1.0/gems/unicorn-4.9.0/lib/unicorn/socket_helper.rb:158:in `new'
/home/ubuntu/ZenSol/curr/vendor/bundle/ruby/2.1.0/gems/unicorn-4.9.0/lib/unicorn/socket_helper.rb:158:in `bind_listen'
/home/ubuntu/ZenSol/curr/vendor/bundle/ruby/2.1.0/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:242:in `listen'
/home/ubuntu/ZenSol/curr/vendor/bundle/ruby/2.1.0/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:813:in `block in bind_new_listeners!'
/home/ubuntu/ZenSol/curr/vendor/bundle/ruby/2.1.0/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:813:in `each'
/home/ubuntu/ZenSol/curr/vendor/bundle/ruby/2.1.0/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:813:in `bind_new_listeners!'
/home/ubuntu/ZenSol/curr/vendor/bundle/ruby/2.1.0/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:138:in `start'
/home/ubuntu/ZenSol/curr/vendor/bundle/ruby/2.1.0/gems/unicorn-4.9.0/bin/unicorn:126:in `'
/home/ubuntu/ZenSol/curr/vendor/bundle/ruby/2.1.0/bin/unicorn:22:in `load'
/home/ubuntu/ZenSol/curr/vendor/bundle/ruby/2.1.0/bin/unicorn:22:in `' ubuntu@ip-10-0-0-193:~/log$