Commit 17ad4e88 authored by ogom's avatar ogom

Support for GitLab 6.0

parent 02858cfc
......@@ -3,9 +3,9 @@ GitLab Cookbook
Chef to install The GitLab.
* GitLab: 5.4.0
* GitLab Shell: 1.5.0
* Ruby: 1.9.3
* GitLab: 6.0.0
* GitLab Shell: 1.7.0
* Ruby: 2.0.0
* Redis: 2.6.13
* Git: 1.7.12
* Nginx: 1.1.19
......@@ -54,12 +54,13 @@ $ vagrant plugin install vagrant-berkshelf
$ vagrant plugin install vagrant-omnibus
$ git clone git://github.com/ogom/cookbook-gitlab ./gitlab
$ cd ./gitlab/
$ vi ./Vagrantfile
$ vagrant up
```
#### Amazon Web Services
Create instance.
```bash
$ gem install berkshelf
$ vagrant plugin install vagrant-berkshelf
......@@ -69,10 +70,14 @@ $ vagrant box add dummy https://github.com/mitchellh/vagrant-aws/raw/master/dumm
$ git clone git://github.com/ogom/cookbook-gitlab ./gitlab
$ cd ./gitlab/
$ cp ./example/Vagrantfile_aws ./Vagrantfile
$ vi ./Vagrantfile
$ vagrant up --provider=aws
```
HostName setting.
```bash
$ vagrant ssh-config | awk '/HostName/ {print $2}'
$ vi ./Vagrantfile
$ editor ./Vagrantfile
$ vagrant provision
```
......@@ -87,7 +92,7 @@ $ cd ./chef-repo/
$ echo 'cookbook "gitlab", github: "ogom/cookbook-gitlab"' >> ./Berksfile
$ berks install --path ./cookbooks
$ knife solo prepare vagrant@127.0.0.1 -p 2222 -i ~/.vagrant.d/insecure_private_key
$ vi ./nodes/127.0.0.1.json
$ editor ./nodes/127.0.0.1.json
$ knife solo cook vagrant@127.0.0.1 -p 2222 -i ~/.vagrant.d/insecure_private_key --no-chef-check
```
......@@ -153,6 +158,7 @@ Add `gitlab::update` to `run_list`.
...
"run_list":[
"gitlab::update",
"gitlab::initial",
"gitlab::install"
]
}
......
......@@ -53,7 +53,8 @@ Vagrant.configure("2") do |config|
config.ssh.max_tries = 40
config.ssh.timeout = 120
# Install the latest version of Chef by the Vagrant Omnibus
# Install the version of Chef by the Vagrant Omnibus
# version is :latest or "11.4.0"
config.omnibus.chef_version = :latest
# The path to the Berksfile to use with Vagrant Berkshelf
......
......@@ -6,12 +6,12 @@ if platform_family?("rhel")
else
packages = %w{
build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev
curl openssh-server checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev
curl openssh-server checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev python-docutils
}
end
default['gitlab']['packages'] = packages
default['gitlab']['ruby'] = "1.9.3-p392"
default['gitlab']['ruby'] = "2.0.0-p247"
# User
default['gitlab']['user'] = "git"
......@@ -20,12 +20,12 @@ default['gitlab']['home'] = "/home/git"
# GitLab shell
default['gitlab']['shell_repository'] = "git://github.com/gitlabhq/gitlab-shell.git"
default['gitlab']['shell_revision'] = "v1.5.0"
default['gitlab']['shell_revision'] = "v1.7.0"
default['gitlab']['shell_path'] = "/home/git/gitlab-shell"
# GitLab hq
default['gitlab']['repository'] = "git://github.com/gitlabhq/gitlabhq.git"
default['gitlab']['revision'] = "v5.4.0"
default['gitlab']['revision'] = "6-0-stable"
default['gitlab']['path'] = "/home/git/gitlab"
# GitLab shell config
......
......@@ -50,10 +50,6 @@ Vagrant.configure("2") do |config|
:database_password => "datapass"
}
}
chef.run_list = [
"postfix",
"gitlab::initial",
"gitlab::install"
]
chef.run_list = []
end
end
......@@ -4,7 +4,7 @@ maintainer_email 'ogom@outlook.com'
license 'MIT'
description 'Installs/Configures GitLab'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.5.1'
version '0.6.0'
recipe "gitlab::initial", "Setting the initial"
recipe "gitlab::install", "Installation"
......
......@@ -11,7 +11,7 @@ end
remote_file "#{Chef::Config['file_cache_path']}/git-#{git['version']}.zip" do
source git['url']
mode 00644
mode 0644
not_if "test -f #{Chef::Config['file_cache_path']}/git-#{git['version']}.zip"
end
......
......@@ -66,14 +66,13 @@ end
end
end
### Copy the example Puma config
template File.join(gitlab['path'], "config", "puma.rb") do
source "puma.rb.erb"
### Copy the example Unicorn config
template File.join(gitlab['path'], "config", "unicorn.rb") do
source "unicorn.rb.erb"
user gitlab['user']
group gitlab['group']
variables({
:path => gitlab['path'],
:env => gitlab['env']
:path => gitlab['path']
})
end
......@@ -82,6 +81,7 @@ bash "git config" do
code <<-EOS
git config --global user.name "GitLab"
git config --global user.email "gitlab@#{gitlab['host']}"
git config --global core.autocrlf input
EOS
user gitlab['user']
group gitlab['group']
......@@ -117,8 +117,10 @@ bundle_without = []
case gitlab['database_adapter']
when 'mysql'
bundle_without << 'postgres'
bundle_without << 'aws'
when 'postgresql'
bundle_without << 'mysql'
bundle_without << 'aws'
end
case gitlab['env']
......@@ -130,7 +132,10 @@ else
end
execute "bundle install" do
command "#{gitlab['bundle_install']} --without #{bundle_without.join(" ")}"
command <<-EOS
PATH="/usr/local/bin:$PATH"
#{gitlab['bundle_install']} --without #{bundle_without.join(" ")}
EOS
cwd gitlab['path']
user gitlab['user']
group gitlab['group']
......@@ -139,7 +144,10 @@ end
### db:setup
execute "rake db:setup" do
command "bundle exec rake db:setup RAILS_ENV=#{gitlab['env']}"
command <<-EOS
PATH="/usr/local/bin:$PATH"
bundle exec rake db:setup RAILS_ENV=#{gitlab['env']}
EOS
cwd gitlab['path']
user gitlab['user']
group gitlab['group']
......@@ -154,7 +162,10 @@ end
### db:migrate
execute "rake db:migrate" do
command "bundle exec rake db:migrate RAILS_ENV=#{gitlab['env']}"
command <<-EOS
PATH="/usr/local/bin:$PATH"
bundle exec rake db:migrate RAILS_ENV=#{gitlab['env']}
EOS
cwd gitlab['path']
user gitlab['user']
group gitlab['group']
......@@ -169,7 +180,10 @@ end
### db:seed_fu
execute "rake db:seed_fu" do
command "bundle exec rake db:seed_fu RAILS_ENV=#{gitlab['env']}"
command <<-EOS
PATH="/usr/local/bin:$PATH"
bundle exec rake db:seed_fu RAILS_ENV=#{gitlab['env']}
EOS
cwd gitlab['path']
user gitlab['user']
group gitlab['group']
......
......@@ -35,7 +35,10 @@ end
## Do setup
execute "gitlab-shell install" do
command "./bin/install"
command <<-EOS
PATH="/usr/local/bin:$PATH"
./bin/install
EOS
cwd gitlab['shell_path']
user gitlab['user']
group gitlab['group']
......
......@@ -5,18 +5,30 @@
gitlab = node['gitlab']
# Stop server
service "gitlab" do
action :stop
end
# Ruby
include_recipe "ruby_build"
ruby_build_ruby gitlab['ruby'] do
prefix_path "/usr/local/"
action :reinstall
end
# Get latest code
## gitlab and gitlab-shell
file File.join(gitlab['home'], ".gitlab_start") do
action :delete
end
## bundle install
file File.join(gitlab['home'], ".gemrc") do
action :delete
end
## rake db:migrate
file File.join(gitlab['home'], ".gitlab_migrate") do
action :delete
end
......@@ -18,8 +18,14 @@ production: &base
host: <%= @host %>
port: <%= @port %>
https: false
# Uncomment and customize to run in non-root path
# Note that ENV['RAILS_RELATIVE_URL_ROOT'] in config/puma.rb may need to be changed
# Uncomment and customize the last line to run in a non-root path
# WARNING: This feature is no longer supported
# Note that three settings need to be changed for this to work.
# 1) In your application.rb file: config.relative_url_root = "/gitlab"
# 2) In your gitlab.yml file: relative_url_root: /gitlab
# 3) In your unicorn.rb: ENV['RAILS_RELATIVE_URL_ROOT']
#
# relative_url_root: /gitlab
# Uncomment and customize if you can't use the default user to run GitLab (default: 'git')
......@@ -32,11 +38,19 @@ production: &base
# Email address of your support contact (default: same as email_from)
support_email: <%= @support_email %>
## Project settings
## User settings
default_projects_limit: 10
# signup_enabled: true # default: false - Account passwords are not sent via the email if signup is enabled.
# default_can_create_group: false # default: true
# username_changing_enabled: false # default: true - User can change her username/namespace
## Users management
# signup_enabled: true # default: false - Account passwords are not sent via the email if signup is enabled.
## Automatic issue closing
# If a commit message matches this regular express, all issues referenced from the matched text will be closed
# if it's pushed to a project's default branch.
# issue_closing_pattern: "^([Cc]loses|[Ff]ixes) +#\d+"
## Default project features settings
default_projects_features:
issues: true
......@@ -66,6 +80,11 @@ production: &base
# ## :project_id - GitLab project identifier
# ## :issues_tracker_id - Project Name or Id in external issue tracker
# new_issue_url: "http://redmine.sample/projects/:issues_tracker_id/issues/new"
#
# jira:
# project_url: "http://jira.sample/issues/?jql=project=:issues_tracker_id"
# issues_url: "http://jira.sample/browse/:id"
# new_issue_url: "http://jira.sample/secure/CreateIssue.jspa"
## Gravatar
gravatar:
......
# GitLab user. git by default
user: <%= @user %>
# Url to gitlab instance. Used for api calls. Should be ends with slash.
# Url to gitlab instance. Used for api calls. Should end with a slash.
gitlab_url: <%= @url %>
http_settings:
# user: someone
# password: somepass
# ca_file: /etc/ssl/cert.pem
# ca_path: /etc/pki/tls/certs
self_signed_cert: false
# Repositories path
# REPOS_PATH MUST NOT BE A SYMLINK!!!
repos_path: "<%= @repos_path %>"
# File used as authorized_keys for gitlab user
......@@ -22,3 +25,15 @@ redis:
port: <%= @redis_port %>
# socket: /tmp/redis.socket # Only define this if you want to use sockets
namespace: <%= @namespace %>
# Log file.
# Default is gitlab-shell.log in the root directory.
# log_file: "<%= File.join(@home, "gitlab-shell", "gitlab-shell.log") %>"
# Log level. INFO by default
log_level: INFO
# Audit usernames.
# Set to true to see real usernames in the logs instead of key ids, which is easier to follow, but
# incurs an extra API call on every gitlab-shell command.
audit_usernames: false
......@@ -2,7 +2,7 @@
# GITLAB
# Maintainer: @randx
# App Version: 5.2
# App Version: 6.0
### BEGIN INIT INFO
# Provides: gitlab
......@@ -14,13 +14,12 @@
# Description: GitLab git repository management
### END INIT INFO
APP_ROOT="<%= @path %>"
APP_USER="<%= @user %>"
DAEMON_OPTS="-C $APP_ROOT/config/puma.rb"
DAEMON_OPTS="-c $APP_ROOT/config/unicorn.rb -E <%= @env %>"
PID_PATH="$APP_ROOT/tmp/pids"
SOCKET_PATH="$APP_ROOT/tmp/sockets"
WEB_SERVER_PID="$PID_PATH/puma.pid"
WEB_SERVER_PID="$PID_PATH/unicorn.pid"
SIDEKIQ_PID="$PID_PATH/sidekiq.pid"
STOP_SIDEKIQ="RAILS_ENV=<%= @env %> bundle exec rake sidekiq:stop"
START_SIDEKIQ="RAILS_ENV=<%= @env %> bundle exec rake sidekiq:start"
......@@ -51,8 +50,8 @@ start() {
exit 1
else
if [ `whoami` = root ]; then
execute "rm $SOCKET_PATH/gitlab.socket"
execute "RAILS_ENV=<%= @env %> bundle exec puma $DAEMON_OPTS"
execute "rm -f $SOCKET_PATH/gitlab.socket"
execute "RAILS_ENV=<%= @env %> bundle exec unicorn_rails $DAEMON_OPTS > /dev/null 2>&1 &"
execute "mkdir -p $PID_PATH && $START_SIDEKIQ > /dev/null 2>&1 &"
echo "$DESC started"
fi
......@@ -81,7 +80,7 @@ restart() {
if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then
echo "Restarting $DESC..."
kill -USR2 `cat $WEB_SERVER_PID`
execute "mkdir -p $PID_PATH && $STOP_SIDEKIQ > /dev/null 2>&1 &"
execute "mkdir -p $PID_PATH && $STOP_SIDEKIQ > /dev/null 2>&1"
if [ `whoami` = root ]; then
execute "mkdir -p $PID_PATH && $START_SIDEKIQ > /dev/null 2>&1 &"
fi
......@@ -96,7 +95,7 @@ status() {
cd $APP_ROOT
check_pid
if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then
echo "$DESC / Puma with PID $PID is running."
echo "$DESC / Unicorn with PID $PID is running."
echo "$DESC / Sidekiq with PID $SPID is running."
else
echo "$DESC is not running."
......
# Sample verbose configuration file for Unicorn (not Rack)
#
# This configuration file documents many features of Unicorn
# that may not be needed for some applications. See
# http://unicorn.bogomips.org/examples/unicorn.conf.minimal.rb
# for a much simpler configuration file.
#
# See http://unicorn.bogomips.org/Unicorn/Configurator.html for complete
# documentation.
# Use at least one worker per core if you're on a dedicated server,
# more will usually help for _short_ waits on databases/caches.
worker_processes 2
# Since Unicorn is never exposed to outside clients, it does not need to
# run on the standard HTTP port (80), there is no reason to start Unicorn
# as root unless it's from system init scripts.
# If running the master process as root and the workers as an unprivileged
# user, do this to switch euid/egid in the workers (also chowns logs):
# user "unprivileged_user", "unprivileged_group"
# Help ensure your application will always spawn in the symlinked
# "current" directory that Capistrano sets up.
working_directory "<%= @path %>" # available in 0.94.0+
# listen on both a Unix domain socket and a TCP port,
# we use a shorter backlog for quicker failover when busy
listen "<%= @path %>/tmp/sockets/gitlab.socket", :backlog => 64
listen "127.0.0.1:8080", :tcp_nopush => true
# nuke workers after 30 seconds instead of 60 seconds (the default)
timeout 30
# feel free to point this anywhere accessible on the filesystem
pid "<%= @path %>/tmp/pids/unicorn.pid"
# By default, the Unicorn logger will write to stderr.
# Additionally, ome applications/frameworks log to stderr or stdout,
# so prevent them from going to /dev/null when daemonized here:
stderr_path "<%= @path %>/log/unicorn.stderr.log"
stdout_path "<%= @path %>/log/unicorn.stdout.log"
# combine Ruby 2.0.0dev or REE with "preload_app true" for memory savings
# http://rubyenterpriseedition.com/faq.html#adapt_apps_for_cow
preload_app true
GC.respond_to?(:copy_on_write_friendly=) and
GC.copy_on_write_friendly = true
# Enable this flag to have unicorn test client connections by writing the
# beginning of the HTTP headers before calling the application. This
# prevents calling the application for connections that have disconnected
# while queued. This is only guaranteed to detect clients on the same
# host unicorn runs on, and unlikely to detect disconnects even on a
# fast LAN.
check_client_connection false
before_fork do |server, worker|
# the following is highly recomended for Rails + "preload_app true"
# as there's no need for the master process to hold a connection
defined?(ActiveRecord::Base) and
ActiveRecord::Base.connection.disconnect!
# The following is only recommended for memory/DB-constrained
# installations. It is not needed if your system can house
# twice as many worker_processes as you have configured.
#
# This allows a new master process to incrementally
# phase out the old master process with SIGTTOU to avoid a
# thundering herd (especially in the "preload_app false" case)
# when doing a transparent upgrade. The last worker spawned
# will then kill off the old master process with a SIGQUIT.
old_pid = "#{server.config[:pid]}.oldbin"
if old_pid != server.pid
begin
sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU
Process.kill(sig, File.read(old_pid).to_i)
rescue Errno::ENOENT, Errno::ESRCH
end
end
#
# Throttle the master from forking too quickly by sleeping. Due
# to the implementation of standard Unix signal handlers, this
# helps (but does not completely) prevent identical, repeated signals
# from being lost when the receiving process is busy.
# sleep 1
end
after_fork do |server, worker|
# per-process listener ports for debugging/admin/migrations
# addr = "127.0.0.1:#{9293 + worker.nr}"
# server.listen(addr, :tries => -1, :delay => 5, :tcp_nopush => true)
# the following is *required* for Rails + "preload_app true",
defined?(ActiveRecord::Base) and
ActiveRecord::Base.establish_connection
# if preload_app is true, then you may also want to check and
# restart any other shared sockets/descriptors such as Memcached,
# and Redis. TokyoCabinet file handles are safe to reuse
# between any number of forked children (assuming your kernel
# correctly implements pread()/pwrite() system calls)
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