lib/docker-sync/sync_strategy/unison.rb in docker-sync-0.5.4 vs lib/docker-sync/sync_strategy/unison.rb in docker-sync-0.5.5
- old
+ new
@@ -20,11 +20,11 @@
@sync_name = sync_name
# if a custom image is set, apply it
if @options.key?('image')
@docker_image = @options['image']
else
- @docker_image = 'eugenmayer/unison:0.3'
+ @docker_image = 'eugenmayer/unison:2.51.2.0'
end
begin
Dependencies::Unison.ensure!
rescue StandardError => e
say_status 'error', "#{@sync_name} has been configured to sync with unison, but no unison available", :red
@@ -145,30 +145,45 @@
say_status 'ok', "Starting unison for sync #{@sync_name}", :white
container_name = get_container_name
volume_name = get_volume_name
env = {}
- say_status 'ok', 'sync_user is no longer supported, since it ise no needed, use sync_userid only please', :yellow if @options.key?('sync_user')
+ raise 'sync_user is no longer supported, since it ise no needed, use sync_userid only please' if @options.key?('sync_user')
+ env['UNISON_SRC'] = '-socket 5000'
+ env['UNISON_DEST'] = '/app_sync'
+
+
+ env['MONIT_ENABLE'] = 'false'
+ env['MONIT_INTERVAL'] = ''
+ env['MONIT_HIGH_CPU_CYCLES'] = ''
+
+ env['UNISON_ARGS'] = ''
ignore_strings = expand_ignore_strings
- env['UNISON_EXCLUDES'] = ignore_strings.join(' ')
+ env['UNISON_ARGS'] << ignore_strings.join(' ')
+ env['UNISON_WATCH_ARGS'] = ''
+
env['MAX_INOTIFY_WATCHES'] = @options['max_inotify_watches'] if @options.key?('max_inotify_watches')
if @options['sync_userid'] == 'from_host'
env['OWNER_UID'] = Process.uid
else
env['OWNER_UID'] = @options['sync_userid'] if @options.key?('sync_userid')
end
+ # start unison-image in unison socket mode mode
+ env['HOSTSYNC_ENABLE']=0
+ env['UNISONSOCKET_ENABLE']=1
+
additional_docker_env = env.map{ |key,value| "-e #{key}=\"#{value}\"" }.join(' ')
running = `docker ps --filter 'status=running' --filter 'name=#{container_name}' --format "{{.Names}}" | grep '^#{container_name}$'`
if running == ''
say_status 'ok', "#{container_name} container not running", :white if @options['verbose']
exists = `docker ps --filter "status=exited" --filter "name=#{container_name}" --format "{{.Names}}" | grep '^#{container_name}$'`
if exists == ''
say_status 'ok', "creating #{container_name} container", :white if @options['verbose']
run_privileged = ''
run_privileged = '--privileged' if @options.key?('max_inotify_watches') #TODO: replace by the minimum capabilities required
- cmd = "docker run -p '#{@options['sync_host_ip']}::#{UNISON_CONTAINER_PORT}' -v #{volume_name}:#{@options['dest']} -e VOLUME=#{@options['dest']} -e TZ=${TZ-`readlink /etc/localtime | sed -e 's,/usr/share/zoneinfo/,,'`} #{additional_docker_env} #{run_privileged} --name #{container_name} -d #{@docker_image}"
+ cmd = "docker run -p '#{@options['sync_host_ip']}::#{UNISON_CONTAINER_PORT}' -v #{volume_name}:#{@options['dest']} -e APP_VOLUME=#{@options['dest']} -e TZ=${TZ-`readlink /etc/localtime | sed -e 's,/usr/share/zoneinfo/,,'`} #{additional_docker_env} #{run_privileged} --name #{container_name} -d #{@docker_image}"
else
say_status 'ok', "starting #{container_name} container", :white if @options['verbose']
cmd = "docker start #{container_name} && docker exec #{container_name} supervisorctl restart unison"
end
else