This document contains code for a Jenkins pipeline that defines stages for compiling, testing, packaging, deploying, and smoke testing a build. It also contains code to send notifications to Typetalk if the build fails. Additional code shows how to fetch pull request branches from a Git remote and check if a pull request is open for a given branch.
This document summarizes a microservices meetup hosted by @mosa_siru. Key points include:
1. @mosa_siru is an engineer at DeNA and CTO of Gunosy.
2. The meetup covered Gunosy's architecture with over 45 GitHub repositories, 30 stacks, 10 Go APIs, and 10 Python batch processes using AWS services like Kinesis, Lambda, SQS and API Gateway.
3. Challenges discussed were managing 30 microservices, ensuring API latency below 50ms across availability zones, and handling 10 requests per second with nginx load balancing across 20 servers.
The document discusses the meaning and etymology of the word "acceptable". It can mean adequate or satisfactory, but not necessarily preferred. Violence is never an acceptable response, even if people are frustrated. The document provides various online resources for learning more about the word such as dictionaries and language learning tools.
10. (1) プレイリスト一覧を表示 Rakefile では、通常の Ruby の文法でなんでも処理を記述可能 冒頭で bin と data のディレクトリの変数への格納処理を実施 directory : 引数のディレクトリを作成 desc : rake –T のタスク一覧を表示したときに説明文を掲載可能 タスクの簡単な説明を記述する task タスク名 do 処理内容 end : ここでは実際の処理 playlist --show を実行 > cat Rakefile bin = File.join(File.dirname(__FILE__), “bin”) data = File.join(File.dirname(__FILE__), “data”) directory data desc “show all video’s title and other info” task :show do sh “#{bin}/playlist --show” end > rake –T rake show # show all video’s title and other info
11. (2) プレイリストから選択し動画 URL を保存 Rake のタスクで引数が必要な場合 タスク名のあとに 引数名 = 値 を書く 環境変数「引数名」に値が文字列として格納される 環境変数は定数 ENV からハッシュとしてアクセス可能 明示的に失敗させる場合は、 fail メソッドを使う 標準エラーに文字列を表示。 exit code (1) で異常終了 desc "download youtube video" task :download do |t| no = ENV["no"] unless no fail “please specify number. ex) rake download no=4“ end sh “#{bin}/playlist --no #{no}” end > rake download no=4
12. (3) 字幕ダウンロード (4)字幕の形式を変換 rule ".timedtext" => [".url"] do |t| sh "#{bin}/timedtext-dl #{t.source}" end rule ".srt" => [".timedtext"] do |t| sh "#{bin}/timedtext2srt #{t.source}" end > rake data/ F6k8lTrAE2g.srt rule を使うと、拡張子から必要なタスクを考えることができる 書き方は rule target => source do |t| 処理 end target を生成するときに依存するファイルを source に記述する source は1個の文字列。複数あれば配列で指定する。 t.source で、最初の依存するファイル を取得する timedtext-dl ~ .url timedtext2srt ~ .timedtext
13. (5) 動画をダウンロード youtube-dl はカレントディレクトリに保存 see http://rg3.github.com/youtube-dl/ 22: mp4 1280x720, 18 : mp4 480x360, 17: 3gp(176x144) Rake タスク内では任意のコードを実行できるため、 open( filename ).read でファイルの内容を取得可能 異常終了すると困る場合は、 system を利用する or で文をつなげると正常終了するまで続けられる Dir.chdir ( dir ) do statements end で statements の処理を実行するディレクトリを変更可能 > rake data/ F6k8lTrAE2g.mp4 rule ".mp4" => [".url"] do |t| url = open(t.source).read.chomp Dir.chdir(File.dirname(t.name)) do system("#{bin}/youtube-dl", "-f", “18", "-c", url) or system("#{bin}/youtube-dl", "-f", "17", "-c", url) or sh("#{bin}/youtube-dl", "-f", “22", "-c", url) end end
14. (6) 字幕付動画を作成 rule target => sources の sources 配列の要素が Proc オブジェクトの場合、依存ファイルの推定ロジックを 独自に実装可能 下記の例であれば、 target が data/F6k8lTrAE2g.eng.mp4 であれば、 data/F6k8lTrAE2g.mp4 と data/F6k8lTrAE2g.srt が sources になる ブロックの引数 t は target のファイル名 rule target => sources do |t| statements end の t は Rake::Task オブジェクト t.name : target のファイル名 > rake data/ F6k8lTrAE2g.eng.mp4 rule “.eng.mp4” => [proc{|t| t.gsub(".eng.mp4", ".mp4")}, proc{|t| t.gsub(".eng.mp4", ".srt")}] do |t| Dir.chdir(File.dirname(t.name)) do sh "#{bin}/embed_cc #{File.basename t.name}" end end
15. 複数の Rake タスクの組み合わせ実行(1) 一連のタスクを一度の Rake で実行したい URL の取得?動画 DL ? 字幕 DL? 字幕変換?字幕?動画合成 rake は依存関係は自己解決するので下記の実行でOK 内部的に rake を呼び出す場合 > rake download no=23 > rake data/BZhxyXTHA3I/BZhxyXTHA3I.eng.mp4 task :captioned_video do no = ENV[“no”] unless no fail “please specify no.” end sh “rake –f #{__FILE__} download no=#{no}” video_id = %x(#{bin}/playlist --no #{no} --video_id).chomp sh “rake –f #{__FILE__} #{data}/#{video_id}/#{video_id}.eng.mp4” end > rake captioned_video no=23 no に対応する video_id を取得
16. 複数の Rake タスクを自動実行(2) 他の Rake タスクを実行するより良い方法 Rake::Task[‘ task_name ’].invoke sh による方法よりも、 Rakefile の呼び出しや Ruby VM の起動 回数を軽減できる 環境変数なども引き継いで利用することができる 環境変数などを引き継ぎたくない場合は内部で rake を呼び出す task :captioned_video2 do no = ENV[“no”] unless no fail “please specify no.” end Rake::Task[“download”].invoke video_id = %x(#{bin}/playlist --no #{no} --video_id).chomp target = “#{data}/#{video_id}/#{video_id}.eng.mp4” Rake::Task[target].invoke end > rake captioned_video2 no=23 no に対応する video_id を取得 タスク(ファイルタスク) 名を動的に生成
19. Rake 落穂拾い( 1 ): file rule のように拡張子から推測される場合でないときは file を使う 個別のファイルごとに依存関係を指定したい場合に用いる > cat Rakefile file " F6k8lTrAE2g .timedtext" => " F6k8lTrAE2g .url" do |t| sh "#{bin}/timedtext-dl #{t.source}" end
20. Rake 落穂拾い(2): namespace Rake のタスクを分類したいときは namespace を使う タスクに “ -” などを含めたいときは、 %s() リテラルを使う > cat Rakefile data = File.join(File.dirname(__FILE__), “data”) namespace :zip do task :srt do Dir.chdir data do sh “zip srt.zip **/*.srt” end end task %s(eng-mp4) do Dir.chdir data do sh “zip eng-mp4.zip **/*.eng.mp4” end end end > rake zip:srt zip srt.zip **/*.srt