The physical architecture of the production environment includes several machines that perform different tasks (rake tasks), all of them on the same database.
One of the tasks will do a large UPDATE on the table, which usually returns a postgres stub if other tasks are performed.
I already have a rake task to gracefully stop other tasks, but I can only do it from local machines.
What I want to achieve:
task :big_update => :environment do stop_tasks_on_another_servers
where stop_tasks_on_another_servers should do the rake task on other servers.
My best attempt was to use the gem https://github.com/capistrano/sshkit . Itβs the same as Capistrano, but I still donβt see a step here. I am trying to do the following on the rails console in a production machine:
require 'sshkit/dsl' hosts = ['machine1', 'machine2'] on hosts do within "/home/me/project/current" do with rails_env: :production do rake "stop_tasks" end end end
But it returns:
INFO [70a0610a] Running /usr/bin/env rake stop_tasks on machine1 SSHKit::Command::Failed: rake stdout: Nothing written
What am I missing or is there an easier way to do remote tasks?
ruby ruby-on-rails rake
dcarneiro
source share