lib/tasks_scheduler/daemon.rb in tasks_scheduler-0.3.0 vs lib/tasks_scheduler/daemon.rb in tasks_scheduler-0.4.0

- old
+ new

@@ -1,13 +1,16 @@ +# frozen_string_literal: true + require 'open3' module TasksScheduler class Daemon - ACTIONS = %w(status start stop restart).freeze + ACTIONS = %w[status start stop restart].freeze class << self def execute(action) raise "Action not allowed: #{action} (Allowed: #{ACTIONS})" unless ACTIONS.include?(action) + command = ['bundle', 'exec', 'tasks_scheduler', action] Dir.chdir(Rails.root) do Open3.popen3(env_args, *command) do |_stdin, stdout, stderr, wait_thr| { action: action, env_args: env_args.map { |k, v| "#{k}=#{v}" }.join(' | '), command: command.join(' '), status: wait_thr.value.to_i, stdout: stdout.read,