Class: FunCi::Pipeline::PipelineForker
- Inherits:
-
Object
- Object
- FunCi::Pipeline::PipelineForker
- Defined in:
- lib/fun_ci/pipeline/pipeline_forker.rb
Class Method Summary collapse
- .fork_pipeline(commit_hash:, branch:, db_path:) ⇒ Object
- .run_in_child(commit_hash:, branch:, db_path:) ⇒ Object
- .sync_launcher(db_path:, pipeline_run_id:, job_id:, executor:) ⇒ Object
Class Method Details
.fork_pipeline(commit_hash:, branch:, db_path:) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/fun_ci/pipeline/pipeline_forker.rb', line 10 def self.fork_pipeline(commit_hash:, branch:, db_path:) pid = fork do run_in_child(commit_hash: commit_hash, branch: branch, db_path: db_path) end Process.detach(pid) end |
.run_in_child(commit_hash:, branch:, db_path:) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/fun_ci/pipeline/pipeline_forker.rb', line 17 def self.run_in_child(commit_hash:, branch:, db_path:) db = Persistence::Database.connection(db_path) recorder = Persistence::DbRecorder.new(db) Trigger.new( project_root: Dir.pwd, commit_hash: commit_hash, branch: branch, stdout: File.open(File::NULL, "w"), recorder: recorder, background_launcher: method(:sync_launcher) ).run recorder.close end |
.sync_launcher(db_path:, pipeline_run_id:, job_id:, executor:) ⇒ Object
31 32 33 34 35 |
# File 'lib/fun_ci/pipeline/pipeline_forker.rb', line 31 def self.sync_launcher(db_path:, pipeline_run_id:, job_id:, executor:) recorder = Persistence::DbRecorder.for_background(db_path, pipeline_run_id) BackgroundWrapper.new(recorder: recorder, job_id: job_id, executor: executor).run recorder.close end |