I have some ruby code (a sidekiq job) which looks like this:
module WorkerJobs
class MyJob < SidekiqWorker
def perform country
# Exec, ``, system, Spawn ... whatever?
# ????
end
end
end
I would like to have the ruby code start a command like this (which takes several hours to complete):
"cd ~/my_dir/production && nohub Rscript --vanilla main.r --country #{country} > /home/deployer/my_dir/shared/log/log_#{country}.log 2>&1 &"
The goal is to get the script started and the sidekiq job to complete without waiting for anything (since the script takes hours to run), so sidekiq can move on and do other jobs. Sidekiq/ruby does not need to know any more details of the state of the job what so ever.
I tried using system()
but that seems to not send the stdout/err to the specified log file for some reason? I tried reading about other ways of executing the script but I can't figure out which method is the right one to use in this case. Again, while the script runs the sidekiq process/thread that started it might stop/start/do-what-ever it should NOT influence the script