Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • G gitlabhq1
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 21
    • Issues 21
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 12
    • Merge requests 12
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • gpt
  • large_projects
  • gitlabhq1
  • Merge requests
  • !8486

Merged
Created Dec 24, 2014 by Administrator@rootOwner

Gracefully shutdown services in Docker container

  • Overview 17
  • Commits 1
  • Changes 4

Created by: kfei

The problem is docker stop only sends SIGTERM to the PID 1 inside the container, and the PID 1 (/bin/sh -c ...) does not take care of signals. Hence the services (e.g., postgresql, redis, sidekiq, etc) never have chances to graceful shutdown. Docker just kills the container after its 10 seconds timeout by default.

What this commit does:

  • Add a wrapper as the entrypoint of Docker container. Which starts services through runit, reconfigure Gitlab by gitlab-ctl and gracefully shutdown all services when a SIGTERM is received.
  • Create an assets directory for assets.
  • Add .dockerignore file.

Now you'll see the following log messages after docker stop:

SIGTERM signal received, try to gracefully shutdown all services...
ok: down: logrotate: 1s, normally up
ok: down: nginx: 0s, normally up
ok: down: postgresql: 1s, normally up
ok: down: redis: 0s, normally up
ok: down: sidekiq: 0s, normally up
ok: down: unicorn: 0s, normally up

Signed-off-by: kfei [email protected]

Assignee
Assign to
Reviewer
Request review from
Time tracking
Source branch: github/fork/kfei/docker/graceful-shutdown