Tag: gitlab

  • Gitlab 日常维护

    安装完gitlab只是第一步,后期维护还需要费力。

    文件约定

    VERSION 文件

    每个项目要增加这个文件,里面写着版本号, 效果见 https://gitlab.com/gitlab-org/gitlab-ce 右则导航栏,方便查看当前版本号。

    .gitignore

    避免提交一堆垃圾文件,及时加上.gitignore文件,有在线工具生成 https://www.gitignore.io/

    版本升级

    参考官方提供的文档 https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/update/upgrader.md 操作,一般不会遇到遇到很大的问题。如果本地修改一些文件,自动升级的脚本会执行git stash存档,同步完后,需要手动 git stash pop

    但不会是一劳永逸,lib 目录下一些配置更新了,还需要对照版本升级说明 https://github.com/gitlabhq/gitlabhq/tree/master/doc/update 手动修改 。

    以上的方式,比较适合不需要对gitlab大修改,如果定制自己的UI或页面,最好建立自己的分支:

    su - git
    cd /home/git/gitlab/
    git checkout -b my_branch
    1. Stop gitlab service
    2. Run git fetch –all
    3. Run git branch 7-5-stable origin/7-5-stable (replace with appropriate version)
    4. Run git rebase 7-5-stable my_branch
    5. Follow the rest of instructions (db:migrate, assets:precompile, etc.)

    参考: http://axilleas.me/en/blog/2014/custom-gitlab-login-page/

    代码备份

    已经有人写了一个脚本脚本,见 https://github.com/sund/auto-gitlab-backup 定期把备份数据拷贝到备机,避免硬盘挂掉的悲剧,更保险一点,需要每月拷贝到移动硬盘上存档。

    性能优化

    Nginx

    根据CPU,work数跟CPU数一样。

  • CentOs 6.5 安装 GitLab 笔记

    硬件要求: https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/install/requirements.md
    注意了,使用阿里云最便宜的主机,内存只有1G,会不够的哦,需要使用 swap交换分区,具体操作自行Google。

    虽然可以按照官方文档 https://github.com/gitlabhq/gitlab-recipes/tree/master/install/centos 从头到尾 ctrl+c、ctrl+v,但有些地方需要注意的。

    使用Ruby镜像

    在运行

    gem install bundler --no-doc

    之前,参考这个 http://ruby.taobao.org/ ,使用淘宝提供的镜像,感谢阿里。否则要等半天。

    nginx启动问题

    [root@git gitlab-shell]# service nginx restart
    Stopping nginx: [FAILED]
    Starting nginx: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
    nginx: [emerg] bind() to [::]:443 failed (98: Address already in use)
    nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
    nginx: [emerg] bind() to [::]:443 failed (98: Address already in use)
    nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
    nginx: [emerg] bind() to [::]:443 failed (98: Address already in use)
    nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
    nginx: [emerg] bind() to [::]:443 failed (98: Address already in use)
    nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
    nginx: [emerg] bind() to [::]:443 failed (98: Address already in use)

    编辑 /etc/nginx/conf.d/gitlab.conf,将ipv6端口注释掉,我们还没有高级的使用ipv6。
    listen 0.0.0.0:80;
    # listen [::]:80 default_server;

    listen 0.0.0.0:443 ssl;
    #listen [::]:443 ssl default_server;

    nginx再启动,运行正常,打开网页报 500错误,查看 log发现:

    == Seed from /home/git/gitlab/db/fixtures/production/001_admin.rb
    2014-11-08T15:52:20Z 25461 TID-otwilgzbo INFO: Sidekiq client with redis options {:url=>”unix:/var/run/redis/redis.sock”, :namespace=>”resque:gitlab”}
    rake aborted!

    Errno::EACCES: Permission denied – connect(2) for /var/run/redis/redis.sock

    简单粗暴的方式,把权限都打开了,

    # chmod 777 /var/run/redis/redis.sock

    不过每次都要设置,终极方案是要再补一刀。
    # echo -e 'unixsocketperm 775' | sudo tee -a /etc/redis.conf

    邮件发送问题

    默认安装postfix,死活没有发送出去,查看日志cat /var/log/maillog,才知道要配置一下 主机,域名,编辑 /etc/postfix/main.cf,把myhostname,mydomain这两个值取消注释,填上你的值。

    myhostname = git.XXX.com
    #myhostname = virtual.domain.tld

    # The mydomain parameter specifies the local internet domain name.
    # The default is to use $myhostname minus the first component.
    # $mydomain is used as a default value for many other configuration
    # parameters.
    #
    mydomain = XXX.com

    如果是阿里云主机需要打开这个:
    #myorigin = $myhostname
    myorigin = $mydomain

    然后重启。测试邮件是否可以发出去,简单的方式是使用mail 命令行发送:

    mail -s "hello world” your_email

    回车,随便输入几个字,ctrl +d 结束输入。

    修改logo

    在 /home/git/gitlab/app/assets 这目录下,

    images/brand_logo.png
    images/favicon.ico
    images/logo-black.png
    images/logo-white.png

    把这几个图片改成你自己的,再重新编译资源文件:

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

    重启 gitlab。

    修改默认皮肤

    编译 config/gitlab.yml
    # default_theme: 2 # default: 2

    注释取消,记得要与上面的这一行 default_projects_limit: 10 对齐,多个空格少个空格都不行,不然启动报错,rails新手会经常犯错。当然,每个开发成员可以定制主题,Profile Settings -> Design,爱哪选哪。

    其他注意

    默认master分支是受保护的,developer成员没有权限提交,所以,要开发成员组自己创建分支,管理员才有权限 merge进来。

    btw:) windows用户使用可能比较蛋疼,他们不太喜欢在命令行敲,需要有个学习适应的过程。

    Puma 替换 Unicorn

    为性能考虑,使用Puma,不过要跟jruby使用,不然会遇到多线程并发问题。参考 这篇 http://icyleaf.com/2014/01/moving-unicorn-to-puma-on-gitlab/

    运行的时候,遇到:
    [root@git gitlab]# service gitlab start
    /etc/init.d/gitlab: line 38: PPID: readonly variable
    Starting puma: /etc/init.d/gitlab: Usage: daemon [+/-nicelevel] {program}

    ^[[Ating sidekiq: [ OK ]

    PPID跟系统的冲突了,改成 UPID即可。已经提交补丁,https://gitlab.com/lytsing/gitlab-recipes/commit/3c8d0a35f54f93caac28bac464829dba7e6dc736