Installing GitLab on FreeBSD 10

Source : https://raw.githubusercontent.com/gitlabhq/gitlab-recipes/master/install/freebsd/freebsd-10.md

1. Update system

pkg update
pkg upgrade

2. Install dependencies

pkg install sudo bash icu cmake pkgconf git go nginx node ruby ruby21-gems logrotate redis postgresql94-server postgresql94-contrib postfix krb5
gem install bundler --no-ri --no-rdoc

Add this to /etc/rc.conf:

# GitLab services
redis_enable="YES"
postgresql_enable="YES"
gitlab_enable="YES"

# Web server
nginx_enable="YES"

# Postfix/Sendmail
postfix_enable="YES"
sendmail_enable="NO"
sendmail_submit_enable="NO"
sendmail_outbound_enable="NO"
sendmail_msp_queue_enable="NO"

3. Create git user

Create user git :

pw add user -n git -m -s /usr/local/bin/bash -c "GitLab"

Add git user to redis group :

pw user mod git -G redis

4. Set up Postgres database

As root, make sure that Postgres is running:

service postgresql start

Set up the database:

# Initialize First start of PG DB
service postgresql initdb

# Initialise Postgres db
service postgresql start

# Log in to Postgres user account
su - pgsql

# Connect to Postgres database
psql -d template1

When logged into the database:

# Create a user for GitLab
template1=# CREATE USER git CREATEDB;

# Create the GitLab production database & grant all privileges on database
template1=# CREATE DATABASE gitlabhq_production OWNER git encoding='UTF8';

# Create extension
CREATE EXTENSION pg_trgm;

# Quit the database session
template1=# \q

Then type exit to drop back to the root user. Try connecting to the new database with the git user:

su - git
psql -d gitlabhq_production
CREATE EXTENSION pg_trgm;

If this succeeds, quit the database session by typing \q or hitting CTRL-D.

5. Install and set up Redis

Back up the original Redis config file:

cp /usr/local/etc/redis.conf /usr/local/etc/redis.conf.orig

Edit /usr/local/etc/redis.conf to obtain:

unixsocket /usr/local/var/run/redis/redis.sock
unixsocketperm 770

daemonize yes
pidfile /var/run/redis/redis.pid

port 6379
tcp-backlog 511

timeout 0
tcp-keepalive 0
loglevel notice
logfile /var/log/redis/redis.log

databases 16

save 900 1
save 300 10
save 60 10000

stop-writes-on-bgsave-error yes

rdbcompression yes

rdbchecksum yes

dbfilename dump.rdb
dir /var/db/redis/

slave-serve-stale-data yes
slave-read-only yes

repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
slave-priority 100

appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no

auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes

lua-time-limit 5000

slowlog-log-slower-than 10000
slowlog-max-len 128

latency-monitor-threshold 0
notify-keyspace-events ""

hash-max-ziplist-entries 512
hash-max-ziplist-value 64

list-max-ziplist-entries 512
list-max-ziplist-value 64

set-max-intset-entries 512

zset-max-ziplist-entries 128
zset-max-ziplist-value 64

hll-sparse-max-bytes 3000

activerehashing yes

client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60

hz 10

aof-rewrite-incremental-fsync yes

Then:

mkdir -p /usr/local/var/run/redis
chown redis:redis /usr/local/var/run/redis
chmod 755 /usr/local/var/run/redis

And we restart Redis:

service redis restart

6. Install and set up GitLab

Change to git home directory:

cd /home/git

Clone GitLab source:

sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 7-7-stable gitlab

Go to GitLab source folder:

cd /home/git/gitlab

Copy the example GitLab config:

sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml

Edit the GitLab configuration file:

sudo -u git -H vim config/gitlab.yml

The option host: should be set to your domain, e.g. “gitlab.mysite.com”.
The line bin_path: should be set to FreeBSD’s git location: /usr/local/bin/git.
Change /home/ to be /usr/home/ (home is a symbolic link that doesn’t work)

As root:

cd /home/git/gitlab
chown -R git log/
chown -R git tmp/
chmod -R u+rwX,go-w log/
chmod -R u+rwX tmp/

Make folder for satellites and set the right permissions:

sudo -u git -H mkdir /home/git/gitlab-satellites
sudo -u git -H chmod u+rwx,g=rx,o-rwx /home/git/gitlab-satellites

Make sure GitLab can write to the tmp/pids/ and tmp/sockets/ directories:

sudo -u git -H chmod -R u+rwX tmp/pids/
sudo -u git -H chmod -R u+rwX tmp/sockets/

Make sure GitLab can write to the public/uploads/ directory:

mkdir -p public/uploads
sudo -u git -H chmod -R u+rwX  public/uploads

Copy the example Unicorn config:

sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb

Set the number of workers to at least the number of cores:

sudo -u git -H vim config/unicorn.rb

Copy the example Rack attack config:

sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb

Configure Git global settings for git user, useful when editing via web

# Edit user.email according to what is set in gitlab.yml
sudo -u git -H git config --global user.name "GitLab"
sudo -u git -H git config --global user.email "example@example.com"
sudo -u git -H git config --global core.autocrlf input

Copy Redis connection settings:

sudo -u git -H cp config/resque.yml.example config/resque.yml

Configure Redis to use the modified socket path:

# Change 'production' line to 'unix:/usr/local/var/run/redis/redis.sock'
sudo -u git -H vim config/resque.yml

Copy database config:

sudo -u git -H cp config/database.yml.postgresql config/database.yml

Install Ruby Gems:

sudo -u git -H bundle install --deployment --without development test mysql aws

7. GitLab Shell

Run the rake task for installing gitlab-shell:

sudo -u git -H bundle exec rake gitlab:shell:install[v2.4.1] REDIS_URL=unix:/usr/local/var/run/redis/redis.sock RAILS_ENV=production

Edit the gitlab-shell config:

# Change /home/* to be /usr/home/*  (home is a symbolic link that doesn't work)
# Change the 'socket' option to '/usr/local/var/run/redis/redis.sock'
# Change the 'gitlab_url' option to 'http://localhost:8080/'
# Don't bother configuring any SSL stuff in here because it's used internally
sudo -u git -H vim /home/git/gitlab-shell/config.yml

8. Initialise Database

Initialize Database and Activate Advanced Features:

sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production GITLAB_ROOT_PASSWORD=yourpassword
# Type 'yes' to create the database tables.
# When done you see 'Administrator account created:'

9. Init script

Download the FreeBSD init script as root:

wget -O /usr/local/etc/rc.d/gitlab https://gitlab.com/gitlab-org/gitlab-recipes/raw/master/init/init/freebsd/gitlab-unicorn

10. Check Configuration and Compile Assets

cd /home/git/gitlab
sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production

If this all passes (all green and/or no errors are reported), then go ahead and compile all of the assets for GitLab. This can take ~10-15 minutes on a smaller machine, so don’t panic if it takes a while!

sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production

11. Start GitLab service

As root:

service gitlab start

12. Nginx

You might want to create /usr/local/etc/nginx/conf.d/ and include it in nginx.conf first.

wget -O /usr/local/etc/nginx/conf.d/gitlab.conf https://gitlab.com/gitlab-org/gitlab-ce/raw/master/lib/support/nginx/gitlab

Edit /usr/local/etc/nginx/conf.d/gitlab.conf and replace git.example.com with your FQDN. Make sure to read the comments in order to properly set up SSL.

Add nginx user to git group:

pw usermod -a -G git nginx
chmod g+rx /home/git/

Finally start nginx with:

service nginx start

Troubleshooting

504 – Gateway Timed Out errors

  • Check the logs! Look in /home/git/gitlab/log for clues.
  • Check what’s running! The command sockstat -4l usually gives an idea of which services are running on which ports. (Redis uses port 6379, Unicorn uses port 8080, and Postgres uses port 5432).

What it usually boils down to:

  • GitLab’s assets haven’t been precompiled (there is a command above)
  • Postgres isn’t running or the database isn’t set up properly
  • Redis isn’t running
  • Nginx isn’t set up properly

Unicorn / nginx: “Failed to set accept_filter=httpready”

This is to do with an HTTP buffering kernel module in FreeBSD that some HTTP servers expect to be loaded. Run this:

kldload accf_http
echo 'accf_http_load="YES"' >> /boot/loader.conf

sudo service gitlab restart
sudo service redis restart
sudo service nginx restart

Très bonne présentation organisation DevOps

Mise en place d’une organisation DevOps

Cyrille Le Clerc

Comme le mouvement Agile a rapproché donneurs d’ordre et équipes de réalisation autour d’une vision commune orientée « produit », le mouvement DevOps rapproche aujourd’hui les équipes de développement (DEV) et d’exploitation (OPS) autour d’une vision commune orientée « service », afin de mieux concilier réactivité et qualité de service.

DevOps aborde le paradoxe entre des équipes projets qui cherchent à livrer toujours plus fréquemment des nouvelles fonctionnalités d’une part et d’autre part des équipes d’exploitation qui cherchent à stabiliser et fiabiliser les systèmes tout en maitrisant leur coût. Read the rest of this entry »

awk Tutorial

La commande awk

Philosophie

On parle souvent de awk comme d’une version améliorée de sed. En effet, on retrouve la notion de portée de commande et de manipulation de texte, mais à mon avis, cette comparaison s’arrête la. Si sed dispose d’une commande if, l’on ne peut parler de langage de programmation alors que cette notion s’applique totalement à awk. Il n’est pas question ici de traiter totalement awk mais juste de vous donner un bref aperçu de sa puissance.

Dû à la complexité de awk, il ne nous sera pas possible de traiter ce langage de façon extensive. Aussi, nous allons procéder à un rapide tutorial dans la première partie et donner une référence rapide des fonctionnalités les plus utilisées dans une seconde. Read the rest of this entry »

15 Practical Grep Command Examples In Linux / UNIX

You should get a grip on the Linux grep command.

This is part of the on-going 15 Examples series, where 15 detailed examples will be provided for a specific command or functionality.  Earlier we discussed 15 practical examples for Linux find command,  Linux command line history and mysqladmin command.


In this article let us review 15 practical examples of Linux grep command that will be very useful to both newbies and experts.
Read the rest of this entry »

Simple Vi Cheat Sheet

Un petit pense-bête bien pratique sur les commandes Vim Read the rest of this entry »

NTFS Cloning and shrinking

“Honey, I shrunk the filesystem!”

Recently I bought a solid-state harddisk, an Intel X25M. I wanted to use this disk in my Windows development system, without having to do a fresh install of Windows XP. I really didn’t want to install all my applications again, not to speak of all the custom configurations and tweaks I usually apply to Windows to make it palatable. So I thought I’d just make a image copy of my old harddisk to this new one, and be done with it.

Read the rest of this entry »

Freenas/ZFS and FreeNAS expansion

Disclaimer: Use this info at your own risk, don’t come to me if all your data disappears one day. But it works for me.

Read the rest of this entry »

Freebsd Disk management GEOM : Howto

1. Pré-requis : présentation de GEOM

GEOM [1] [2] est un framework d’abstraction d’accès à des raw-devices via des classes (CONCAT, ELI, LABEL, MIRROR, NOP, RAID3, SHSEC, STRIPE, VINUM) ; chaque classe représente un typ1. Pré-requis : présentation de GEOM

GEOM [1] [2] est un framework d’abstraction d’accès à des raw-devices via des classes (CONCAT, ELI, LABEL, MIRROR, NOP, RAID3, SHSEC, STRIPE, VINUM) ; chaque classe représente un type d’action sur ces raw-devices. Il est possible de combiner plusieurs classes sur un même device, et ce, dans différents ordres, ce qui éloigne fortement GEOM des autres ” volume managers ” qui ont une typologie beaucoup plus stricte.
Un peu de vocabulaire :

  • Une classe implémente un type particulier d’action sur ces raw-devices (disques durs IDE, SATA, SCSI ; clés USB ; fichiers ” filesystem ” montés sur une loopback mdconfig(3)) ;
  • Un provider est le device résultant de l’action de GEOM sur ces raw-devices ;
  • Un consumer est le device sur lequel s’applique la classe, au départ, le device physique.

Le handbook comporte un chapitre très complet sur GEOM [3] : ” Chapter 18 GEOM : Modular Disk Transformation “.

Read the rest of this entry »

Memo AIX <5.0

Mémento de commandes d’administration pour AIX (≤ 5.x)


Read the rest of this entry »

sed Tutorial

sed tutorial
sed introduction
sed examples #1
sed commands
regular expressions
more sed examples

intro hometop of the pageemail

sed – Stream EDitor – works as a filter processing input line by line.
Sed reads one line at a time, chops off the terminating newline, puts what is left into the pattern space (buffer) where the sed script can process it (often using regular expressions), then if there anything to print – sed appends a newline and prints out the result (usually to stdout). Read the rest of this entry »

 

Switch to our mobile site