You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A ruby module to assist in capturing stdout/stderr from a detached thread in jRuby
create some temp files (but not Tempfiles since they would be GC'd too quickly)
append standard file descriptor redirects to the commands that we'll run in the detached spawned process, i.e. 1>>stdout_tempfile_path 2>>stderr_tempfile_path
tack on a final command that will trigger copying the files to S3 regardless of exit status of original commands, i.e. {original commands with io redirection &&'d together}; bundle exec rake cleanup_task
cleanup other io redirection temp files older than some threshold
Example usage:
job_identifier="install_and_run_cowsay"uuid=SecureRandom.hexcommands=["cd #{Dir.pwd}",IoRedirect.command_with_io_redirection("apt-get install cowsay",job_identifier,uuid),IoRedirect.command_with_io_redirection("cowsay I Love nix",job_identifier,uuid)].join(" && ") + "; bundle exec rake io_redirect:copy_logs_to_s3[#{job_identifier},#{uuid}]"pid=Process.spawn(commands)# => 12345thread=Process.detach(pid)# => #<Thread:0x60e1d87c run>
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters