lib/vagrant-vaimo-unison/command.rb in vagrant-vaimo-unison-0.2.0 vs lib/vagrant-vaimo-unison/command.rb in vagrant-vaimo-unison-1.0.0
- old
+ new
@@ -7,42 +7,12 @@
require_relative 'shell_command'
require_relative 'unison_sync'
module VagrantPlugins
module Unison
- class CommandOnce < Vagrant.plugin('2', :command)
+ class CommandSync < Vagrant.plugin("2", :command)
include UnisonSync
-
- def self.synopsis
- 'sync the unison shared folder once'
- end
-
- def execute
- status = nil
- with_target_vms do |machine|
- execute_sync_command(machine) do |command|
- command.batch = true
- command.terse = true
- command = command.to_s
-
- @env.ui.info 'Running unison once'
- @env.ui.info " #{command}"
-
- status = system(command)
- @env.ui.info "**** unison exited. success: #{status} ****"
- end
- end
- if status
- return 0
- end
-
- 1
- end
- end
-
- class CommandPolling < Vagrant.plugin("2", :command)
- include UnisonSync
attr_accessor :bg_thread
def self.synopsis
'sync the unison shared folder forever, by polling for changes'
end
@@ -51,10 +21,11 @@
status = nil
with_target_vms do |machine|
@bg_thread = watch_vm_for_memory_leak(machine)
execute_sync_command(machine) do |command|
command.repeat = true
+ command.batch = true
command.terse = true
command = command.to_s
@env.ui.info "Running #{command}"
@@ -102,11 +73,11 @@
if _unison_proc_returnval == ''
puts 'Unison not running in VM'
next
end
pid, mem_pct_unison = _unison_proc_returnval.strip.split(' ')
- mem_unison = (total_mem.to_f * mem_pct_unison.to_f/100).round(1)
+ mem_unison = (total_mem.to_f * mem_pct_unison.to_f / 100).round(1)
# Debugging: uncomment to log every loop tick
# puts "Unison running as #{pid} using #{mem_unison} mb"
if mem_unison > mem_cap_mb
puts "Unison using #{mem_unison}MB memory is over limit of #{mem_cap_mb}MB, restarting"
`#{ssh_command_text} kill -HUP #{pid} 2>/dev/null`
@@ -114,25 +85,44 @@
end
end
end
end
+ class CommandOnce < Vagrant.plugin('2', :command)
+ include UnisonSync
+
+ def self.synopsis
+ 'sync the unison shared folder once'
+ end
+
+ def execute
+ @env.ui.info 'The command is deprecated, use vagrant unison-sync'
+ end
+ end
+
+ class CommandPolling < Vagrant.plugin("2", :command)
+ include UnisonSync
+ attr_accessor :bg_thread
+
+ def self.synopsis
+ 'sync the unison shared folder forever, by polling for changes'
+ end
+
+ def execute
+ @env.ui.info 'The command is deprecated, use vagrant unison-sync'
+ end
+ end
+
class CommandCleanup < Vagrant.plugin('2', :command)
def self.synopsis
- 'remove all unison supporting state on local and remote system'
+ 'Remove archives and configuration from host and guest. Keeps files in guest (need to remove manually if needed)'
end
def execute
with_target_vms do |machine|
- guest_path = UnisonPaths.new(@env, machine).guest
-
command = "rm -rf ~/Library/'Application Support'/Unison/*"
@env.ui.info "Running #{command} on host"
system(command)
-
- command = "rm -rf #{guest_path}/* #{guest_path}/..?* #{guest_path}/.[!.]*"
- @env.ui.info "Running #{command} on guest VM (delete all files from directory including hidden ones)"
- machine.communicate.sudo(command)
command = 'rm -rf ~/.unison'
@env.ui.info "Running #{command} on guest VM"
machine.communicate.execute(command)
end