Skip to content

Commit

Permalink
Merge pull request #521 from ricmatsui/rm-monit
Browse files Browse the repository at this point in the history
Use Monit to auto restart if CPU usage high in Native OSX strategy
  • Loading branch information
EugenMayer committed Jan 24, 2018
2 parents 4955d75 + 22d0456 commit d88c4f3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions example/docker-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,11 @@ syncs:
watch_args: '-v'
# optional: default is fswatch, if set to disable, no watcher will be used and you would need to start the sync manually
watch_strategy: 'fswatch'

# monit can be used to monitor the health of unison in the native_osx strategy and can restart unison if it detects a problem
# optional: use this to switch monit monitoring on
monit_enabled: false
# optional: use this to change how many seconds between each monit check (cycle)
monit_interval: 5
# optional: use this to change how many consecutive times high cpu usage must be observed before unison is restarted
monit_high_cpu_cycles: 2
10 changes: 10 additions & 0 deletions lib/docker-sync/sync_strategy/native_osx.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ def start_container
env['OWNER_UID'] = @options['sync_userid'] if @options.key?('sync_userid')
end

monit_options = {
monit_enable: 'MONIT_ENABLE',
monit_interval: 'MONIT_INTERVAL',
monit_high_cpu_cycles: 'MONIT_HIGH_CPU_CYCLES',
}

monit_options.each do |key, env_key|
env[env_key] = @options[key.to_s] if @options.key?(key.to_s)
end

host_disk_mount_mode = '' # see https://github.com/moby/moby/pull/31047
host_disk_mount_mode = ":#{@options['host_disk_mount_mode']}" if @options.key?('host_disk_mount_mode')

Expand Down

0 comments on commit d88c4f3

Please sign in to comment.