Commit 0aae33d9 authored by Kirill Smelkov's avatar Kirill Smelkov

gitlab/unicorn.rb: First round of slaposification

Convert unicorn parameters to slapos and configure it to listen on unix
socket only.

( Omnibus configures unicorn to listen on unix socket and
  loopback TCP, mainly because gitlab-shell could not connect to unicorn
  via unix socket until recently:

      https://gitlab.com/gitlab-org/gitlab-shell/commit/184385ac

  But as it can now, there is no point to keep on TCP port open )

To be able to do such configuration we add stub to unicorn service
section (to create needed directories where to keep the socket).

There will be follow-up patch which configures unicorn pre/post-forking
actions, which is not trivial and thus better be done on its own.

/cc @kazuhiko, @jerome
parent c3f1f0a9
...@@ -58,6 +58,13 @@ configuration.backup_keep_time = 0 ...@@ -58,6 +58,13 @@ configuration.backup_keep_time = 0
configuration.git_max_size = configuration.git_max_size =
configuration.git_timeout = configuration.git_timeout =
# unicorn
configuration.unicorn_worker_timeout = 60
configuration.unicorn_worker_processes = 2
# unicorn advanced # unicorn advanced
configuration.unicorn_backlog_socket = 1024
configuration.unicorn_worker_memory_limit_min = 200*(1024**2) configuration.unicorn_worker_memory_limit_min = 200*(1024**2)
configuration.unicorn_worker_memory_limit_max = 250*(1024**2) configuration.unicorn_worker_memory_limit_max = 250*(1024**2)
...@@ -192,6 +192,10 @@ mode = 0600 ...@@ -192,6 +192,10 @@ mode = 0600
[unicorn.rb] [unicorn.rb]
<= gitlab-etc-template <= gitlab-etc-template
template = {{ unicorn_rb_in }} template = {{ unicorn_rb_in }}
context-extra =
section unicorn unicorn
section directory directory
section gitlab_work gitlab-work
...@@ -397,6 +401,20 @@ depend = ...@@ -397,6 +401,20 @@ depend =
log = ${redis:log}/*.log log = ${redis:log}/*.log
######################
# unicorn worker #
######################
[unicorn-dir]
recipe = slapos.cookbook:mkdirectory
srv = ${directory:srv}/unicorn
log = ${directory:log}/unicorn
[unicorn]
srv = ${unicorn-dir:srv}
log = ${unicorn-dir:log}
socket = ${:srv}/unicorn.socket
############# #############
# cron # # cron #
......
...@@ -5,24 +5,23 @@ ...@@ -5,24 +5,23 @@
# https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/files/gitlab-cookbooks/gitlab/templates/default/unicorn.rb.erb # https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/files/gitlab-cookbooks/gitlab/templates/default/unicorn.rb.erb
# (last updated for omnibus-gitlab 8.2.3+ce.0-0-g8eda093) # (last updated for omnibus-gitlab 8.2.3+ce.0-0-g8eda093)
{% from 'macrolib.cfg.in' import cfg with context %}
# What ports/sockets to listen on, and what options for them. # What ports/sockets to listen on, and what options for them.
<%- @listen.each do |port, options| %> # we listen only on unix socket
listen "<%= port %>", <%= options %> listen "{{ unicorn.socket }}", :backlog => {{ cfg('unicorn_backlog_socket') }}
<%- end %> #listen "127.0.0.1:8888", :tcp_nopush => true
<%- if @working_directory %> working_directory '{{ gitlab_work.location }}'
working_directory '<%= @working_directory %>'
<%- end %>
# What the timeout for killing busy workers is, in seconds # What the timeout for killing busy workers is, in seconds
timeout <%= @worker_timeout %> timeout {{ cfg('unicorn_worker_timeout') }}
# Whether the app should be pre-loaded # Whether the app should be pre-loaded
preload_app <%= @preload_app %> preload_app <%= @preload_app %>
# How many worker processes # How many worker processes
worker_processes <%= @worker_processes %> worker_processes {{ cfg('unicorn_worker_processes') }}
<%- if @before_fork %> <%- if @before_fork %>
# What to do before we fork a worker # What to do before we fork a worker
...@@ -38,18 +37,12 @@ after_fork do |server, worker| ...@@ -38,18 +37,12 @@ after_fork do |server, worker|
end end
<%- end %> <%- end %>
<%- if @pid %>
# Where to drop a pidfile # Where to drop a pidfile
pid '<%= @pid %>' pid '{{ directory.run }}/unicorn.pid'
<%- end %>
<%- if @stderr_path %>
# Where stderr gets logged # Where stderr gets logged
stderr_path '<%= @stderr_path %>' stderr_path '{{ unicorn.log }}/unicorn_stderr.log'
<%- end %>
<%- if @stdout_path %>
# Where stdout gets logged # Where stdout gets logged
stdout_path '<%= @stdout_path %>' stdout_path '{{ unicorn.log }}/unicorn_stdout.log'
<%- end %>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment