GitLabをアップデートしてみる

前回、ubuntuにGitLabを導入する手順を書きました。
そのGitLabをアップデートしてみました。

前回導入していたのは、下記の時点のGitLab。

commit 23187d60c4eb3eb2d51459ab18fd16da9caa5b58
Author: Dmitriy Zaporozhets 
Date:   Tue Oct 25 21:07:39 2011 +0300

今回導入したのは、下記の時点のGitLab。

commit c4a575b70b3ee8a25023dd1b4eb2422c54f6b04d
Merge: 79bcdfb 7b5fd14
Author: Nihad Abbasov 
Date:   Wed Nov 16 09:50:05 2011 -0800

1ヶ月もたたないうちにかなりのコミットがされていて驚きました。
かなりの開発スピードみたいです。
UIもがらっと変わって見やすさも向上しています。
また、Network Graphの機能とか追加されていて、かなり使い勝手がよくなっています。

以前のバージョン(1.1.0)だと、コミットに対して日本語でコメントを追加すると、エラーが発生していたりと不具合もあったのですが、
2011/11/16時点の最新版だと解消されているようです。
ただし、コミットログに日本語が含まれている場合、うまく表示されていないのは解消されていないみたいで、別途対処が必要です。

以下、バージョンアップ手順を記録しておきます。

サーバの停止

まずは、バージョンアップの前にGitLabのアプリサーバを停止します。

sqliteのDBをバックアップ

DBの構造にも変更が加えられているようなので、念のためDBのバックアップを取得します。

$ sqlite3 db/production.sqlite3 .dump > /backup/production.sqlite3.backup

git pullで最新のコードを取得

githubから最新のコードにアップデートします。

$ git pull

bundle installでgemの更新を実施

bundle install で最新版に対応したgemをインストールします。
また、併せてannotate_models.gitもチェックアウトされてくるようなので、
プロキシ経由でインストールされる方は要注意です。
proxy経由でのgitコマンド実行についてはこちらをご参考に(http://d.hatena.ne.jp/rx7/20080703/p1)。

$ sudo bundle install
Updating git://github.com/ctran/annotate_models.git
Fetching source index for http://rubygems.org/
Installing rake (0.9.2.2) 
Using ZenTest (4.5.0) 
Using multi_json (1.0.3) 
Installing activesupport (3.1.1) 
Using builder (3.0.0) 
Using i18n (0.6.0) 
Installing activemodel (3.1.1) 
Using erubis (2.7.0) 
Installing rack (1.3.5) 
Installing rack-cache (1.1) 
Using rack-mount (0.8.3) 
Using rack-test (0.6.1) 
Using hike (1.2.1) 
Using tilt (1.3.3) 
Installing sprockets (2.0.3) 
Installing actionpack (3.1.1) 
Installing mime-types (1.17.2) 
Installing polyglot (0.3.3) 
Using treetop (1.4.10) 
Using mail (2.3.0) 
Installing actionmailer (3.1.1) 
Using arel (2.2.1) 
Installing tzinfo (0.3.31) 
Installing activerecord (3.1.1) 
Installing activeresource (3.1.1) 
Using bundler (1.0.21) 
Using rack-ssl (1.3.2) 
Installing json (1.6.1) with native extensions 
Installing rdoc (3.11) 
Using thor (0.14.6) 
Installing railties (3.1.1) 
Installing rails (3.1.1) 
Installing acts-as-taggable-on (2.1.1) 
Using acts_as_list (0.1.4) 
Using addressable (2.2.6) 
Using annotate (2.4.1.beta1) from git://github.com/ctran/annotate_models.git (at master) 
Installing ansi (1.4.1) 
Using autotest (4.4.6) 
Using autotest-rails (4.1.1) 
Using awesome_print (0.4.0) 
Using bcrypt-ruby (3.0.1) 
Using blankslate (2.1.2.4) 
Using nokogiri (1.5.0) 
Installing ffi (1.0.11) with native extensions 
Using childprocess (0.2.2) 
Installing json_pure (1.6.1) 
Using rubyzip (0.9.4) 
Installing selenium-webdriver (2.12.2) 
Using xpath (0.1.4) 
Installing capybara (1.1.2) 
Installing carrierwave (0.5.8) 
Installing coffee-script-source (1.1.3) 
Installing execjs (1.2.9) 
Using coffee-script (2.2.0) 
Using coffee-rails (3.1.1) 
Using daemons (1.1.4) 
Installing database_cleaner (0.7.0) 
Using orm_adapter (0.0.5) 
Installing warden (1.1.0) 
Installing devise (1.5.0) 
Using diff-lcs (1.1.3) 
Using eventmachine (0.12.10) 
Installing faker (1.0.1) 
Using git (1.2.5) 
Using posix-spawn (0.3.6) 
Using grit (2.4.1) from git://github.com/gitlabhq/grit.git (at master) 
Using haml (3.1.3) 
Using haml-rails (0.3.4) 
Using inifile (0.4.1) 
Installing jquery-rails (1.0.17) 
Using kaminari (0.12.4) 
Using launchy (2.0.5) 
Installing letter_opener (0.0.2) 
Installing libv8 (3.3.10.4) 
Installing rubypython (0.5.3) 
Using pygments.rb (0.2.3) 
Installing rails-footnotes (3.7.5) 
Installing rdiscount (1.6.8) with native extensions 
Installing rspec-core (2.7.1) 
Installing rspec-expectations (2.7.0) 
Installing rspec-mocks (2.7.0) 
Installing rspec (2.7.0) 
Installing rspec-rails (2.7.0) 
Installing sass (3.1.10) 
Installing sass-rails (3.1.4) 
Installing seed-fu (2.1.0) 
Installing shoulda-context (1.0.0) 
Installing shoulda-matchers (1.0.0) 
Installing shoulda (3.0.0.beta2) 
Using simplecov-html (0.5.3) 
Installing simplecov (0.5.4) 
Using six (0.2.0) 
Using sqlite3 (1.3.4) 
Using stamp (0.1.6) 
Installing therubyracer (0.9.9) with native extensions 
Installing thin (1.3.1) with native extensions 
Installing turn (0.8.3) 
Installing uglifier (1.1.0) 
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

かなりのgemパッケージがインストールされました。

DBのmigrate

DBのスキーマが変更になっているためmigrateを実行します。

$ sudo bundle exec rake db:migrate RAILS_ENV=production

これでDBが最新に対応します。

サーバ起動

ここまできたらサーバを起動します。

$ ruby script/rails s -e production -p 80 -d

動作確認

アクセスするとかなりUIが変わっているのがわかるかと思います。

エラー発生状況

masterブランチがないリポジトリでのエラー

外部から持ってきたgitリポジトリなどでmasterブランチが存在していないとcommitログを見ようとした場合にエラーになるので、
gitリポジトリにmasterブランチを作成して対応して下さい。
エラーのログはこんな感じです。

Started GET "/sample/commits/4513c99d04fc6901388c51c40c360748cdbc4aec" for xxx.xxx.xxx.xxx at 2011-11-18 19:40:15 +0900
  Processing by CommitsController#show as HTML
  Parameters: {"project_id"=>"sample", "id"=>"4513c99d04fc6901388c51c40c360748cdbc4aec"}
Rendered commits/_diff_head.html.haml (17.3ms)
Rendered commits/_text_file.html.haml (2.3ms)
Rendered commits/_text_file.html.haml (2.6ms)
Rendered commits/_text_file.html.haml (0.8ms)
Rendered commits/_diff.html.haml (123.3ms)
Rendered notes/_form.html.haml (3.1ms)
Rendered notes/_notes_list.html.haml (1.4ms)
Rendered notes/_notes.html.haml (5.1ms)
Rendered commits/show.html.haml within layouts/project (129.6ms)
Rendered layouts/_flash.html.haml (0.1ms)
Rendered layouts/_head_panel.html.erb (6.8ms)
Completed 500 Internal Server Error in 160ms

ActionView::Template::Error (undefined method `id' for nil:NilClass):
    49:             .medium-tags{:style => 'padding: 10px 0 0 10px; width: 210px;'}= tag_list @project
    50: 
    51:         .project-content
    52:           = yield
  app/helpers/application_helper.rb:22:in `commit_name'
  app/views/layouts/project.html.haml:52:in `_app_views_layouts_project_html_haml___3523047045464485670_56639240'
  app/controllers/commits_controller.rb:35:in `show'
Network Graphにアクセスした際にサーバダウン

Network Graphがプロジェクトによっては見れないものがありました。
Network Graphにアクセスすると、サーバがダウンしてしまうことがあるようです。
原因が追いきれず・・・
gritのlazy.rbの中でなにか起こっているみたいです。

/usr/local/ruby/1.9.2/lib/ruby/gems/1.9.1/bundler/gems/grit-ff015074ef35/lib/grit/lazy.rb:27: [BUG] Segmentation fault
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]

 -- control frame ----------
c:2503 p:---- s:10138 b:10138 l:000137 d:000137 CFUNC  :instance_variable_defined?
c:2502 p:0012 s:10134 b:10134 l:001f90 d:000133 LAMBDA /usr/local/ruby/1.9.2/lib/ruby/gems/1.9.1/bundler/gems/grit-ff015074ef35/lib/grit/lazy.rb:27
c:2501 p:---- s:10131 b:10131 l:000130 d:000130 FINISH
c:2500 p:0019 s:10129 b:10129 l:000128 d:000128 METHOD /home/maintain/git/gitlabhq/lib/graph_commit.rb:12
c:2499 p:---- s:10123 b:10123 l:000122 d:000122 FINISH
c:2498 p:0049 s:10121 b:10121 l:000120 d:000120 METHOD /home/maintain/git/gitlabhq/lib/graph_commit.rb:64
c:2497 p:0085 s:10113 b:10113 l:000104 d:000112 BLOCK  /home/maintain/git/gitlabhq/lib/graph_commit.rb:66
c:2496 p:---- s:10110 b:10110 l:000109 d:000109 FINISH
c:2495 p:---- s:10108 b:10108 l:000107 d:000107 CFUNC  :collect
c:2494 p:0055 s:10105 b:10105 l:000104 d:000104 METHOD /home/maintain/git/gitlabhq/lib/graph_commit.rb:64
c:2493 p:0085 s:10097 b:10097 l:000088 d:000096 BLOCK  /home/maintain/git/gitlabhq/lib/graph_commit.rb:66
c:2492 p:---- s:10094 b:10094 l:000093 d:000093 FINISH

・・・略
c:0006 p:0356 s:0042 b:0042 l:000041 d:000041 METHOD /usr/local/ruby/1.9.2/lib/ruby/gems/1.9.1/gems/rack-1.3.5/lib/rack/handler/webrick.rb:59
c:0005 p:0257 s:0030 b:0030 l:000029 d:000029 METHOD /usr/local/ruby/1.9.2/lib/ruby/1.9.1/webrick/httpserver.rb:111
c:0004 p:0393 s:0020 b:0020 l:000019 d:000019 METHOD /usr/local/ruby/1.9.2/lib/ruby/1.9.1/webrick/httpserver.rb:70
c:0003 p:0126 s:0009 b:0009 l:000c18 d:000008 BLOCK  /usr/local/ruby/1.9.2/lib/ruby/1.9.1/webrick/server.rb:183
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:---- s:0002 b:0002 l:000001 d:000001 TOP   
 ---------------------------
 -- Ruby level backtrace information ----------------------------------------
/usr/local/ruby/1.9.2/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
/usr/local/ruby/1.9.2/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'


・・・略

/usr/local/ruby/1.9.2/lib/ruby/gems/1.9.1/gems/actionpack-3.1.1/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
/home/maintain/git/gitlabhq/app/controllers/projects_controller.rb:100:in `graph'
/home/maintain/git/gitlabhq/lib/graph_commit.rb:46:in `index_commits'
/home/maintain/git/gitlabhq/lib/graph_commit.rb:46:in `each'
/home/maintain/git/gitlabhq/lib/graph_commit.rb:48:in `block in i

・・・略

/usr/local/ruby/1.9.2/lib/ruby/gems/1.9.1/bundler/gems/grit-ff015074ef35/lib/grit/lazy.rb:27:in `block (2 levels) in lazy_reader'
/usr/local/ruby/1.9.2/lib/ruby/gems/1.9.1/bundler/gems/grit-ff015074ef35/lib/grit/lazy.rb:27:in `instance_variable_defined?'

 -- C level backtrace information -------------------------------------------
/usr/local/ruby/1.9.2/bin/ruby(rb_vm_bugreport+0xa1) [0x51ba31]
/usr/local/ruby/1.9.2/bin/ruby() [0x55d7fb]
/usr/local/ruby/1.9.2/bin/ruby(rb_bug+0xa5) [0x55ea55]

・・・略

/usr/local/ruby/1.9.2/bin/ruby() [0x518236]
/usr/local/ruby/1.9.2/bin/ruby() [0x50c974]
/usr/local/ruby/1.9.2/bin/ruby() [0x51250d]
/usr/local/ruby/1.9.2/bin/ruby(rb_yield+0x47) [0x5189c7]
/usr/local/ruby/1.9.2/bin/ruby() [0x531af6]
/usr/local/ruby/1.9.2/bin/ruby() [0x518236]

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html