|
40 | 40 |
|
41 | 41 | require_relative "{{GITLAB_INSTALL_DIR}}/lib/gitlab/cluster/lifecycle_events" |
42 | 42 |
|
43 | | -on_restart do |
44 | | - # Signal application hooks that we're about to restart |
45 | | - Gitlab::Cluster::LifecycleEvents.do_before_master_restart |
46 | | -end |
| 43 | +if Gem::Version.new(Puma::Const::PUMA_VERSION) < Gem::Version.new('7.0') |
| 44 | + Gitlab::Cluster::LifecycleEvents.set_puma_options @config.options |
47 | 45 |
|
48 | | -before_fork do |
49 | | - # Signal to the puma killer |
50 | | - Gitlab::Cluster::PumaWorkerKillerInitializer.start(@config.options, puma_per_worker_max_memory_mb: {{PUMA_PER_WORKER_MAX_MEMORY_MB}}, puma_master_max_memory_mb: {{PUMA_MASTER_MAX_MEMORY_MB}}) unless ENV['DISABLE_PUMA_WORKER_KILLER'] |
| 46 | + on_restart do |
| 47 | + # Signal application hooks that we're about to restart |
| 48 | + Gitlab::Cluster::LifecycleEvents.do_before_master_restart |
| 49 | + end |
51 | 50 |
|
52 | | - # Signal application hooks that we're about to fork |
53 | | - Gitlab::Cluster::LifecycleEvents.do_before_fork |
54 | | -end |
| 51 | + on_worker_boot do |
| 52 | + # Signal application hooks of worker start |
| 53 | + Gitlab::Cluster::LifecycleEvents.do_worker_start |
| 54 | + end |
55 | 55 |
|
56 | | -Gitlab::Cluster::LifecycleEvents.set_puma_options @config.options |
57 | | -on_worker_boot do |
58 | | - # Signal application hooks of worker start |
59 | | - Gitlab::Cluster::LifecycleEvents.do_worker_start |
| 56 | + on_worker_shutdown do |
| 57 | + # Signal application hooks that a worker is shutting down |
| 58 | + Gitlab::Cluster::LifecycleEvents.do_worker_stop |
| 59 | + end |
| 60 | +else |
| 61 | + Gitlab::Cluster::LifecycleEvents.set_puma_worker_count(3) |
| 62 | + |
| 63 | + before_restart do |
| 64 | + # Signal application hooks that we're about to restart |
| 65 | + Gitlab::Cluster::LifecycleEvents.do_before_master_restart |
| 66 | + end |
| 67 | + |
| 68 | + before_worker_boot do |
| 69 | + # Signal application hooks of worker start |
| 70 | + Gitlab::Cluster::LifecycleEvents.do_worker_start |
| 71 | + end |
| 72 | + |
| 73 | + before_worker_shutdown do |
| 74 | + # Signal application hooks that a worker is shutting down |
| 75 | + Gitlab::Cluster::LifecycleEvents.do_worker_stop |
| 76 | + end |
60 | 77 | end |
61 | 78 |
|
62 | | -on_worker_shutdown do |
63 | | - # Signal application hooks that a worker is shutting down |
64 | | - Gitlab::Cluster::LifecycleEvents.do_worker_stop |
| 79 | +before_fork do |
| 80 | + # Signal application hooks that we're about to fork |
| 81 | + Gitlab::Cluster::LifecycleEvents.do_before_fork |
65 | 82 | end |
66 | 83 |
|
67 | 84 | # Preload the application before starting the workers; this conflicts with |
|
87 | 104 | json_formatter.call(str) |
88 | 105 | end |
89 | 106 |
|
90 | | -lowlevel_error_handler do |ex, env| |
91 | | - if Raven.configuration.capture_allowed? |
92 | | - Raven.capture_exception(ex, tags: { 'handler': 'puma_low_level' }, extra: { puma_env: env }) |
93 | | - end |
| 107 | +require_relative "{{GITLAB_INSTALL_DIR}}/lib/gitlab/puma/error_handler" |
| 108 | + |
| 109 | +error_handler = Gitlab::Puma::ErrorHandler.new(ENV['RAILS_ENV'] == 'production') |
94 | 110 |
|
95 | | - # note the below is just a Rack response |
96 | | - [500, {}, ["An error has occurred and reported in the system's low-level error handler."]] |
| 111 | +lowlevel_error_handler do |ex, env, status_code| |
| 112 | + error_handler.execute(ex, env, status_code) |
97 | 113 | end |
0 commit comments