Merge branch 'mailroom-service' into 'master'

Make mailroom a normal omnibus service

This is more predictable than what we had before and it makes UDP log shipping not impossible.

See merge request !523
This commit is contained in:
Marin Jankovski 2015-11-16 09:19:00 +00:00
commit 959c1b3f43
8 changed files with 87 additions and 62 deletions

View File

@ -94,7 +94,6 @@ default['gitlab']['gitlab-rails']['incoming_email_start_tls'] = nil
default['gitlab']['gitlab-rails']['incoming_email_email'] = nil
default['gitlab']['gitlab-rails']['incoming_email_password'] = nil
default['gitlab']['gitlab-rails']['incoming_email_mailbox_name'] = nil
default['gitlab']['gitlab-rails']['incoming_email_log_directory'] = "/var/log/gitlab/mailroom"
default['gitlab']['gitlab-rails']['lfs_enabled'] = false
default['gitlab']['gitlab-rails']['lfs_storage_path'] = nil
default['gitlab']['gitlab-rails']['ldap_enabled'] = false
@ -366,6 +365,14 @@ default['gitlab']['gitlab-workhorse']['pprof_listen_addr'] = "''" # put an empty
default['gitlab']['gitlab-workhorse']['dir'] = "/var/opt/gitlab/gitlab-workhorse"
default['gitlab']['gitlab-workhorse']['log_dir'] = "/var/log/gitlab/gitlab-workhorse"
####
# mailroom
####
default['gitlab']['mailroom']['enable'] = false
default['gitlab']['mailroom']['ha'] = false
default['gitlab']['mailroom']['log_dir'] = "/var/log/gitlab/mailroom"
####
# Nginx
####

View File

@ -1,52 +0,0 @@
#
# Copyright:: Copyright (c) 2014 GitLab B.V.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
define :mailroom_service, :rails_app => nil, :user => nil do
svc = params[:name]
user = params[:user]
rails_app = params[:rails_app]
mailroom_log_dir = node['gitlab']['gitlab-rails']['incoming_email_log_directory']
mail_room_config = File.join(node['gitlab']['gitlab-rails']['dir'], "etc", "mail_room.yml")
cookbook_file mail_room_config do
notifies :restart, 'service[mailroom]'
end
directory mailroom_log_dir do
owner user
mode '0700'
recursive true
end
runit_service svc do
template_name 'mailroom'
options({
:rails_app => rails_app,
:user => user,
:log_directory => mailroom_log_dir,
:mail_room_config => mail_room_config
}.merge(params))
log_options node['gitlab']['logging'].to_hash
end
if node['gitlab']['bootstrap']['enable']
execute "/opt/gitlab/bin/gitlab-ctl start #{svc}" do
retries 20
end
end
end

View File

@ -50,6 +50,7 @@ module Gitlab
ci_sidekiq Mash.new
gitlab_workhorse Mash.new
gitlab_git_http_server Mash.new # legacy from GitLab 7.14, 8.0, 8.1
mailroom Mash.new
nginx Mash.new
ci_nginx Mash.new
mattermost_nginx Mash.new
@ -360,6 +361,12 @@ module Gitlab
mattermost_nginx['enable'] = true if mattermost_nginx['enable'].nil?
end
def parse_incoming_email
return unless gitlab_rails['incoming_email_enabled']
mailroom['enable'] = true if mailroom['enable'].nil?
end
def disable_gitlab_rails_services
if gitlab_rails["enable"] == false
redis["enable"] = false
@ -386,6 +393,7 @@ module Gitlab
"sidekiq",
"ci_sidekiq",
"gitlab_workhorse",
"mailroom",
"nginx",
"ci_nginx",
"mattermost_nginx",
@ -425,6 +433,7 @@ module Gitlab
parse_nginx_listen_ports
parse_gitlab_ci
parse_gitlab_mattermost
parse_incoming_email
disable_gitlab_rails_services
# The last step is to convert underscores to hyphens in top-level keys
generate_hash

View File

@ -98,6 +98,7 @@ include_recipe "runit"
"unicorn",
"sidekiq",
"gitlab-workhorse",
"mailroom",
"nginx",
"remote-syslog",
"logrotate",

View File

@ -0,0 +1,47 @@
#
# Copyright:: Copyright (c) 2014 GitLab B.V.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
user = AccountHelper.new(node).gitlab_user
mailroom_log_dir = node['gitlab']['mailroom']['log_dir']
mail_room_config = File.join(node['gitlab']['gitlab-rails']['dir'], "etc", "mail_room.yml")
cookbook_file mail_room_config do
notifies :restart, 'service[mailroom]'
end
directory mailroom_log_dir do
owner user
mode '0700'
recursive true
end
runit_service 'mailroom' do
template_name 'mailroom'
options({
:user => user,
:log_directory => mailroom_log_dir,
:mail_room_config => mail_room_config
}.merge(params))
log_options node['gitlab']['logging'].to_hash.merge(node['gitlab']['mailroom'].to_hash)
end
if node['gitlab']['bootstrap']['enable']
execute "/opt/gitlab/bin/gitlab-ctl start mailroom" do
retries 20
end
end

View File

@ -0,0 +1,20 @@
#
# Copyright:: Copyright (c) 2015 GitLab B.V.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
runit_service "mailroom" do
action :disable
end

View File

@ -21,10 +21,3 @@ sidekiq_service 'sidekiq' do
rails_app 'gitlab-rails'
user account_helper.gitlab_user
end
if node['gitlab']['gitlab-rails']['incoming_email_enabled']
mailroom_service 'mailroom' do
rails_app 'gitlab-rails'
user account_helper.gitlab_user
end
end

View File

@ -1,13 +1,13 @@
#!/bin/sh
cd <%= node['gitlab'][@options[:rails_app]]['dir'] %>/working
cd <%= node['gitlab']['gitlab-rails']['dir'] %>/working
exec 2>&1
# This is useful to see in the logs; mail_room is very quiet
echo 'Runit: starting mail_room'
exec chpst -e /opt/gitlab/etc/<%= @options[:rails_app] %>/env -P \
exec chpst -e /opt/gitlab/etc/gitlab-rails/env -P \
-U <%= @options[:user] %> -u <%= @options[:user] %> \
/opt/gitlab/embedded/bin/bundle exec mail_room \
-c <%= @options[:mail_room_config] %>