Skip to content
Snippets Groups Projects
Commit a5069c05 authored by Jan Provaznik's avatar Jan Provaznik Committed by Ian Baum
Browse files

Run before_fork only once on boot

This aligns behavior of before_fork with Puma where before_fork
is called only on master boot, also none of our code needs to be run
before each worker fork, instead we have a use-case for deleting
Prometheus files only on boot time.

Related https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/29788
parent 06a2570d
No related branches found
No related tags found
Loading
---
title: Run before_fork only once on boot for Unicorn.
merge_request:
author:
type: changed
......@@ -33,16 +33,18 @@ run_once = true
before_fork do |server, worker|
if run_once
# There is a difference between Puma and Unicorn:
# - Puma calls before_fork once when booting up master process
# - Unicorn runs before_fork whenever new work is spawned
# To unify this behavior we call before_fork only once (we use
# this callback for deleting Prometheus files so for our purposes
# it makes sense to align behavior with Puma)
run_once = false
# The Unicorn before_exec hook only gets called on a Unicorn
# restart, but we want to clean things up (e.g. metric files) at
# first boot.
Gitlab::Cluster::LifecycleEvents.do_master_restart
# Signal application hooks that we're about to fork
Gitlab::Cluster::LifecycleEvents.do_before_fork
end
Gitlab::Cluster::LifecycleEvents.do_before_fork
old_pid = "#{server.config[:pid]}.oldbin"
if old_pid != server.pid
begin
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment