Commit 48723dae authored by Carlo Landmeter's avatar Carlo Landmeter
Browse files

config: refactor config management

parent 9f096a6d
../overlay/
\ No newline at end of file
--- ./config.toml.example
+++ ./config.toml.example
@@ -3,7 +3,7 @@
socket_path = "/home/git/gitlab/tmp/sockets/private/gitaly.socket"
# The directory where Gitaly's executables are stored
-bin_dir = "/home/git/gitaly"
+bin_dir = "/usr/local/bin"
# # Optional: listen on a TCP socket. This is insecure (no authentication)
# listen_addr = "localhost:9999"
@@ -40,7 +40,7 @@ path = "/home/git/repositories"
# # You can optionally configure Gitaly to output JSON-formatted log messages to stdout
# [logging]
# # The directory where Gitaly stores extra log files
-dir = "/home/git/gitlab/log"
+# dir = "/home/git/gitlab/log"
# format = "json"
# # Optional: Set log level to only log entries with that severity or above
# # One of, in order: debug, info, warn, errror, fatal, panic
@@ -58,7 +58,7 @@ dir = "/home/git/gitlab/log"
[gitaly-ruby]
# The directory where gitaly-ruby is installed
-dir = "/home/git/gitaly/ruby"
+dir = "/home/git/gitaly-ruby"
# # Gitaly-ruby resident set size (RSS) that triggers a memory restart (bytes)
# max_rss = 200000000
--- ./lib/support/logrotate/gitlab
+++ ./lib/support/logrotate/gitlab
@@ -8,13 +8,5 @@
compress
notifempty
copytruncate
-}
-
-/home/git/gitlab-shell/gitlab-shell.log {
- daily
- missingok
- rotate 90
- compress
- notifempty
- copytruncate
+ maxsize 100M
}
......@@ -2,12 +2,15 @@
set -eu
INITCONF="
gitlab.yml.example
secrets.yml.example
unicorn.rb.example
puma.rb.example
initializers/rack_attack.rb.example
# base config files found in gitlab/config dir
BASECONF="
gitlab/gitlab.yml.example
gitlab/secrets.yml.example
gitlab/unicorn.rb.example
gitlab/puma.rb.example
gitlab/initializers/rack_attack.rb.example
gitaly/config.toml.example
gitlab-shell/config.yml.example
"
create_db() {
......@@ -28,15 +31,22 @@ create_db() {
fi
}
create_init_conf() {
echo "Setting up configurations.."
for config in $INITCONF; do
install -Dm644 /home/git/gitlab/config/$config \
/etc/gitlab/gitlab/${config%.*}
# install config if not yet exist
install_conf() {
local config
for config in $BASECONF; do
if [ ! -f "/etc/gitlab/${config%.*}" ]; then
echo "Installing missing config: ${config%.*}"
local dest=${config%.*}
case $config in gitlab/*) config=${config#*/};; esac
install -Dm644 /home/git/gitlab/config/$config \
/etc/gitlab/$dest
fi
done
# gitlab-shell
install -Dm644 /home/git/gitlab-shell/config.yml.example \
/etc/gitlab/gitlab-shell/config.yml
if [ ! -f "/etc/gitlab/logrotate/gitlab" ]; then
install -Dm644 /home/git/gitlab/lib/support/logrotate/gitlab \
/etc/gitlab/logrotate/gitlab
fi
}
link_config() {
......@@ -64,11 +74,8 @@ prepare_conf() {
link_config "/etc/gitlab/gitlab" "/home/git/gitlab/config"
link_config "/etc/gitlab/ssh" "/etc/ssh"
link_config "/etc/gitlab/nginx" "/etc/nginx"
if [ ! -f /etc/gitlab/logrotate/gitlab.conf ]; then
mkdir -p /etc/gitlab/logrotate
head -n12 /home/git/gitlab/lib/support/logrotate/gitlab \
> /etc/logrotate.d/gitlab
fi
link_config "/etc/gitlab/gitlab-shell" "/home/git/gitlab-shell"
link_config "/etc/gitlab/logrotate/" "/etc/logrotate.d"
}
rebuild_conf() {
......@@ -101,21 +108,6 @@ redis_conf() {
EOF
}
gitaly_config() {
mkdir -p /etc/gitlab/gitaly
cat <<- EOF > /etc/gitlab/gitaly/config.toml
socket_path = "/home/git/gitlab/tmp/sockets/private/gitaly.socket"
bin_dir = "/usr/local/bin"
[[storage]]
name = "default"
path = "/home/git/repositories"
[gitaly-ruby]
dir = "/home/git/gitaly-ruby"
[gitlab-shell]
dir = "/home/git/gitlab-shell"
EOF
}
nginx_config() {
mkdir -p /etc/gitlab/nginx/conf.d
cat <<- EOF > /etc/gitlab/nginx/conf.d/default.conf
......@@ -224,9 +216,8 @@ setup() {
create_db
postgres_conf
redis_conf
gitaly_config
nginx_config
create_init_conf
install_conf
setup_ssh
prepare_dirs
prepare_conf
......@@ -267,16 +258,17 @@ start() {
if [ -f "/etc/gitlab/.version" ]; then
echo "Configuration found"
prepare_dirs
install_conf
prepare_conf
rebuild_conf
upgrade_check
enable_services
else
echo "No configuration found. Running setup.."
setup
fi
echo "$GITLAB_VERSION" > /etc/gitlab/.version
echo "Starting Gitlab.."
enable_services
s6-svscan /run/s6
}
......
......@@ -85,6 +85,7 @@ cd "$gitlab_location"
patch -p0 -i /tmp/gitlab/disable-check-gitaly.patch
patch -p0 -i /tmp/gitlab/unicorn-log-to-stdout.patch
patch -p0 -i /tmp/gitlab/puma-no-redirect.patch
patch -p0 -i /tmp/logrotate/logrotate-defaults.patch
# temporary symlink the example configs to make setup happy
for config in gitlab.yml.example database.yml.postgresql; do
......@@ -105,9 +106,11 @@ GITLAB_SHELL_VERSION=$(cat "$gitlab_location"/GITLAB_SHELL_VERSION)
get_source gitlab-shell $GITLAB_SHELL_VERSION
mv /home/git/src/gitlab-shell-v$GITLAB_SHELL_VERSION /home/git/gitlab-shell
cd /home/git/gitlab-shell
# needed for setup
ln -sf config.yml.example config.yml
patch -p0 -i /tmp/gitlab-shell/gitlab-shell-changes.patch
install -Dm644 config.yml.example "$gitlab_location"/gitlab-shell/config.yml
ln -sf "$gitlab_location"/gitlab-shell/config.yml config.yml
install -Dm644 config.yml.example \
"$gitlab_location"/config/gitlab-shell/config.yml.example
./bin/compile && ./bin/install
# gitlab-shell will not set PATH
ln -s /usr/local/bin/ruby /usr/bin/ruby
......@@ -137,9 +140,11 @@ GITALY_SERVER_VERSION=$(cat "$gitlab_location"/GITALY_SERVER_VERSION)
git clone https://gitlab.com/gitlab-org/gitaly.git -b \
v$GITALY_SERVER_VERSION /home/git/src/gitaly
cd /home/git/src/gitaly
patch -p0 -i /tmp/gitaly/gitaly-set-defaults.patch
make install BUNDLE_FLAGS=--system
mv ruby /home/git/gitaly-ruby
install -Dm644 config.toml.example "$gitlab_location"/gitaly/config.toml
install -Dm644 config.toml.example \
"$gitlab_location"/config/gitaly/config.toml.example
# https://gitlab.com/gitlab-org/gitlab-foss/issues/50937
export NODE_OPTIONS="--max_old_space_size=4096"
......
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