docker-gitlab: Unicorn does not come up (error 502) after hard restart of Docker server

Steps to reproduce

  1. Run GitLab using the guide
  2. Power cycle the server running Docker

Actual result

GitLab will never come up fully, showing error 502.

The docker container logs will have this:

2017-07-26 23:20:38,558 INFO spawned: 'unicorn' with pid 612
2017-07-26 23:20:39,160 INFO exited: unicorn (exit status 1; not expected)
...
2017-07-26 23:20:46,864 INFO spawned: 'unicorn' with pid 647
2017-07-26 23:20:47,312 INFO exited: unicorn (exit status 1; not expected)
2017-07-26 23:20:48,313 INFO gave up: unicorn entered FATAL state, too many start retries too quickly

unicorn_stderr.log will have this:

...
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/unicorn-5.1.0/lib/unicorn/http_server.rb:195:in `pid=': Already running on PID:601 (or pid=/home/git/gitlab/tmp/pids/unicorn.pid is stale) (ArgumentError)
        from /home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/unicorn-5.1.0/lib/unicorn/http_server.rb:127:in `start'
        from /home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/unicorn-5.1.0/bin/unicorn_rails:209:in `<top (required)>'
        from /home/git/gitlab/vendor/bundle/ruby/2.3.0/bin/unicorn_rails:22:in `load'
        from /home/git/gitlab/vendor/bundle/ruby/2.3.0/bin/unicorn_rails:22:in `<main>'

Workaround

The only way to bring up GitLab will be to docker exec into the container, manually delete the stale pid file and restart the container:

docker exec -it gitlab rm /home/git/gitlab/tmp/pids/unicorn.pid && docker restart gitlab

Expected result

GitLab comes up without manual intervention.

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Reactions: 35
  • Comments: 27 (3 by maintainers)

Most upvoted comments

docker exec -it gitlab rm /home/git/gitlab/tmp/pids/unicorn.pid && docker restart gitlab

This solved my issue, thanks 😃

-----me too, thanks!!!

Removing the PID and restarting also solved my issue. Caused by reboot of my Synology NAS.

@solidnerd @sameersbn Can we fix this permanently by adding a cleanup in the entrypoint ?

Example:

#!/bin/bash

#Define cleanup procedure
cleanup() {
    echo "Container stopped, performing cleanup..."
}

#Trap SIGTERM
trap 'cleanup' SIGTERM

#Execute a command
"${@}" &

#Wait
wait $!

#Cleanup
cleanup
docker exec -it gitlab rm /home/git/gitlab/tmp/pids/unicorn.pid && docker restart gitlab

This solved my issue, thanks 😃

This issue has been automatically marked as stale because it has not had any activity for the last 60 days. It will be closed if no further activity occurs during the next 7 days. Thank you for your contributions.

2018년 6월 2일 (토) 오전 11:09, fover0932 notifications@github.com님이 작성:

docker exec -it gitlab rm /home/git/gitlab/tmp/pids/unicorn.pid && docker restart gitlab

This solved my issue, thanks 😃

-----me too, thanks!!!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/sameersbn/docker-gitlab/issues/1305#issuecomment-394049215, or mute the thread https://github.com/notifications/unsubscribe-auth/AEzfyNS3nKC5dlYdnxxZX8NRDwxwuiZyks5t4fPcgaJpZM4OkxsJ .