2
0

More than 1 year has passed since last update.

GitLab開発依存ライブラリからthin gemを排除した

Last updated at Posted at 2022-12-25

GitLab Advent Calendar 2022 25日目。

thinという、"A small and fast Ruby web server" gemがある。tnir とも少し字面が似ている。

GitLabの開発が始まって1年ちょっとたったタイミングで当時、初代GitLab CTO(のちのFellowであり、1年ほど前からGitLab Inc.から離れている)dzaporozhetsにより開発用に導入されたgemである。

dzaporozhets committed on Jan 19, 2013

何が問題か

GitLab開発用に作られたCLI gdk (GitLab Development Kit) というものがあるが、そこのサブコマンドに thin というコマンドがあった。ケースによるが一般的にはライブラリの名前に依存したサブコマンドというのは適切ではないだろう。

また、GitLabのproduction (RAILS_ENV=production) ではPuma(そして今から数年前まではUnicorn)を使っていたのに、ローカルでは別のWebサーバを使うことになっていたということも環境差異を生み出す要因であった。

Thinが(GitLabの開発以外のシチュエーションにおいて)どの程度使われていたかは定かではないが、 https://rubygems.org/search?query=gitlab
からも分かる通り、GitLabで使われるgemはGitLab本体の開発のCIプロセスを通じて大量のgemダウンロードがなされることで知られており、 https://rubygems.org/gems/thin のダウンロード数が増大することはthinの利用状況統計が大きく上振れさせてしまうことも問題であった。

どう解決したか

https://gitlab.com/gitlab-org/gitlab/-/merge_requests/89258 とそこからリンクされる内容なので、詳細はリンクを辿っていただきたい。

https://gitlab.com/gitlab-org/gitlab/-/merge_requests/89258/diffs やdiffだけ見れば単純なので、(gdkサブコマンド問題を)すぐに終わると思っていたが、思いの外、いろいろな意見があったのは新鮮であった。記憶に留めておきたい。

diff --git a/Gemfile b/Gemfile
index 1064c63a5c38bc43ad2ac5835f3682825a28bb60..10db5310ca5185b1fdd7ff6c661367a098488b58 100644
--- a/Gemfile
+++ b/Gemfile
@@ -354,9 +354,6 @@ group :development do
   # Better errors handler
   gem 'better_errors', '~> 2.9.0'
 
-  # thin instead webrick
-  gem 'thin', '~> 1.8.0'
-
   gem 'sprite-factory', '~> 1.7'
 end
 
diff --git a/Gemfile.lock b/Gemfile.lock
index a124621edeb654d941e980b081d8518da0d01ab3..4eeb168ce13842ef4b8c9cd8870b6214098c92e1 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -257,7 +257,6 @@ GEM
       git
     css_parser (1.11.0)
       addressable
-    daemons (1.3.1)
     danger (8.6.1)
       claide (~> 1.0)
       claide-plugins (>= 0.9.2)
@@ -373,7 +372,6 @@ GEM
       tzinfo
     ethon (0.15.0)
       ffi (>= 1.15.0)
-    eventmachine (1.2.7)
     excon (0.90.0)
     execjs (2.8.1)
     expression_parser (0.9.0)
@@ -1348,10 +1346,6 @@ GEM
     test_file_finder (0.1.4)
       faraday (~> 1.0)
     text (1.3.1)
-    thin (1.8.0)
-      daemons (~> 1.0, >= 1.0.9)
-      eventmachine (~> 1.0, >= 1.0.4)
-      rack (>= 1, < 3)
     thor (1.2.1)
     thrift (0.14.0)
     tilt (2.0.10)
@@ -1744,7 +1738,6 @@ DEPENDENCIES
   terser (= 1.0.2)
   test-prof (~> 1.0.7)
   test_file_finder (~> 0.1.3)
-  thin (~> 1.8.0)
   thrift (>= 0.14.0)
   timecop (~> 0.9.1)
   timfel-krb5-auth (~> 0.8)
diff --git a/doc/development/caching.md b/doc/development/caching.md
index 362e4c4cded6326deab3b42cbc581ba42cfaf032..5ae6484436e47d779f5927ed12dfffb6223be103 100644
--- a/doc/development/caching.md
+++ b/doc/development/caching.md
@@ -118,8 +118,8 @@ Is the cache being added "worthy"? This can be hard to measure, but you can cons
     - `tail -f log/development.log | grep "Rendered "`
 - After you're looking in the right place:
   - Remove or comment out sections of code until you find the cause.
-  - Use `binding.pry` to poke about in live requests. This requires a foreground
-    web process like [Thin](https://gitlab.com/gitlab-org/gitlab-development-kit/-/blob/main/doc/howto/pry.md).
+  - Use `binding.pry` to poke about in live requests. This requires a
+    [foreground web process](https://gitlab.com/gitlab-org/gitlab-development-kit/-/blob/main/doc/howto/pry.md).
 
 #### Verification
 

時間もないので、これで終わりにするが、いつか余裕のあるときに改めて理由を振り返ってみたい。

何が嬉しいのか

thineventmachine というgemに依存している。 eventmachine gemもインストールをするのに手こずりがちなgemであるらしい。この10年で mysql2, nokogiri, charlock_holmes と同じくらい、困ったよレポートを見聞きした気がする。

eventmachine というgemからも離れることができたのは非常に嬉しい話である。

まとめ

10年来の相棒であった、thin gemをGitLab開発から除外し、その副次的な作用として、eventmachine gemをも除外できて、developer experienceが改善された。

Resources

お知らせ

本記事は GitLab Advent Calendar 2022 Day 25でした。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0