docker-sync 0.5.13 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 04a9a15570d1faf97af25c0dfa37241a3374c8e0
4
- data.tar.gz: 92fc94323ba31dc7cd0e6935d51ecef7d470d58f
2
+ SHA256:
3
+ metadata.gz: d08392b2115f84c6dd7d37cb28232b4193523d4bb8e45860a9be061cefd88fb5
4
+ data.tar.gz: 18626e0ea9919d701dee2787d32457314bbe4abee642ce26ce23c3a02b5e5145
5
5
  SHA512:
6
- metadata.gz: cba7ebc5e2c0b3214ee0e4456ad5b9ca6ba30cf327aa614983cc437dd6b7e692260e3cd1154c6f27fd6dc2fe22e0581474595cbee4fac118dc2351e4cbe316d7
7
- data.tar.gz: 26ab2e2b6d6cc95c9334991446848d869b12356edc67f6a530d3fc8af1bda6eae0f3fc105098eec1fdf43e314dcfbc46c694f9dc9399ed92cb77c9584ab35f83
6
+ metadata.gz: bf0b3f26f0eb4f2d99b95336e13669e4abef9db285b240011660d5d19bd89485b4940f523adbd1d8bbb6b412af3e251a8e21c4e4d9cd40b43676a897452bcdc5
7
+ data.tar.gz: dbc9ec63c1b187f181e9bf180507cb724a7e54010dc145e80a882f020eab19051400496f72e0b8c5cd078fa8130bd29fce74ab6a188d6162d012dfb70a6e3823
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.13
1
+ 0.7.1
@@ -11,7 +11,7 @@ module DockerSync
11
11
 
12
12
  def self.running?
13
13
  return @running if defined? @running
14
- @running = system('docker ps 2>&1 > /dev/null')
14
+ @running = system('docker ps > /dev/null 2>&1')
15
15
  end
16
16
 
17
17
  def self.ensure!
@@ -2,8 +2,7 @@ module DockerSync
2
2
  module Dependencies
3
3
  module Rsync
4
4
  def self.available?
5
- return @available if defined? @available
6
- @available = find_executable0('rsync')
5
+ find_executable0('rsync')
7
6
  end
8
7
 
9
8
  def self.ensure!
@@ -2,8 +2,7 @@ module DockerSync
2
2
  module Dependencies
3
3
  module Unison
4
4
  def self.available?
5
- return @available if defined? @available
6
- @available = find_executable0('unison')
5
+ find_executable0('unison')
7
6
  end
8
7
 
9
8
  def self.ensure!
@@ -5,6 +5,7 @@ module DockerSync
5
5
  module Unox
6
6
  LEGACY_UNOX_WARNING = 'You installed unison-fsmonitor (unox) the old legacy way (i.e. not using brew). We need to fix that.'.freeze
7
7
  FAILED_TO_REMOVE_LEGACY_UNOX = 'Failed to remove legacy unison-fsmonitor (unox). Please delete /usr/local/bin/unison-fsmonitor manually and try again.'.freeze
8
+ UNSUPPORTED_FSMONITOR = 'You are using unsupported version of unison-fsmonitor, consider installing eugenmayer/dockersync/unox instead'.freeze
8
9
 
9
10
  class << self
10
11
  extend Forwardable
@@ -13,17 +14,19 @@ module DockerSync
13
14
 
14
15
  def self.available?
15
16
  # should never have been called anyway - fix the call that it should check for the OS
16
- raise 'Unox cannot be available for other platforms then MacOS' unless Environment.mac?
17
+ raise 'Unox cannot be available for platforms other than MacOS' unless Environment.mac?
17
18
 
18
- return @available if defined? @available
19
- cmd = 'brew list unox 2>&1 > /dev/null'
20
- @available = Environment.system(cmd)
21
- @available
19
+ return true if brew_package_installed?('unox')
20
+ return false unless brew_package_installed?('unison-fsmonitor')
21
+
22
+ say_status 'warning', UNSUPPORTED_FSMONITOR, :yellow unless @unsupported_fsmonitor_warning_displayed
23
+ @unsupported_fsmonitor_warning_displayed = true
24
+ true
22
25
  end
23
26
 
24
27
  def self.ensure!
25
28
  return if available?
26
- raise 'Unox cannot be installed on other platforms then MacOS' unless Environment.mac?
29
+ raise 'Unox cannot be installed on platforms other than MacOS' unless Environment.mac?
27
30
 
28
31
  cleanup_non_brew_version!
29
32
  PackageManager.install_package('eugenmayer/dockersync/unox')
@@ -41,6 +44,11 @@ module DockerSync
41
44
  def self.non_brew_version_installed?
42
45
  !available? && File.exist?('/usr/local/bin/unison-fsmonitor')
43
46
  end
47
+
48
+ def self.brew_package_installed?(name)
49
+ cmd = "brew list #{name} > /dev/null 2>&1"
50
+ Environment.system(cmd)
51
+ end
44
52
  end
45
53
  end
46
54
  end
@@ -4,11 +4,13 @@ module DockerSync
4
4
  module Environment
5
5
  def self.linux?
6
6
  return @linux if defined? @linux
7
+
7
8
  @linux = OS.linux?
8
9
  end
9
10
 
10
11
  def self.mac?
11
12
  return @mac if defined? @mac
13
+
12
14
  @mac = OS.mac?
13
15
  end
14
16
 
@@ -17,7 +19,7 @@ module DockerSync
17
19
  end
18
20
 
19
21
  def self.system(cmd)
20
- defined?(Bundler) ? Bundler.clean_system(cmd) : Kernel.system(cmd)
22
+ defined?(Bundler) ? Bundler.unbundled_system(cmd) : Kernel.system(cmd)
21
23
  end
22
24
  end
23
25
  end
@@ -48,7 +48,7 @@ module DockerSync
48
48
  end
49
49
 
50
50
  if @config_syncs[name].key?('dest')
51
- puts 'Please do no longer use "dest" in your docker-sync.yml configuration - also see https://github.com/EugenMayer/docker-sync/wiki/1.2-Upgrade-Guide#dest-has-been-removed!'
51
+ puts 'Please do no longer use "dest" in your docker-sync.yml configuration - also see https://docker-sync.readthedocs.io/en/latest/getting-started/upgrade.html#id4'
52
52
  exit 1
53
53
  else
54
54
  @config_syncs[name]['dest'] = '/app_sync'
@@ -23,7 +23,7 @@ module DockerSync
23
23
  if @options.key?('image')
24
24
  @docker_image = @options['image']
25
25
  else
26
- @docker_image = 'eugenmayer/unison:2.51.2.1'
26
+ @docker_image = 'eugenmayer/unison:2.51.3-4.12.0-AMD64'
27
27
  end
28
28
 
29
29
  begin
@@ -42,12 +42,16 @@ module DockerSync
42
42
 
43
43
  out = `#{cmd}`
44
44
  if $?.exitstatus > 0
45
- say_status 'error', "Error starting sync, exit code #{$?.exitstatus}", :red
45
+ error_msg = "Error starting sync, exit code #{$?.exitstatus}"
46
+ say_status 'error', error_msg, :red
46
47
  say_status 'message', out
47
- else
48
48
  TerminalNotifier.notify(
49
- "Synced #{@options['src']}", :title => @sync_name
49
+ "#{error_msg}", :title => @sync_name, :subtitle => @options['src'], group: 'docker-sync'
50
50
  ) if @options['notify_terminal']
51
+ else
52
+ TerminalNotifier.notify(
53
+ "Synced #{@options['src']}", :title => @sync_name, group: 'docker-sync'
54
+ ) if @options['notify_terminal'] && @options['notify_terminal'] != 'errors_only'
51
55
  say_status 'ok', "Synced #{@options['src']}", :white
52
56
  if @options['verbose']
53
57
  say_status 'output', out
@@ -14,16 +14,16 @@ module DockerSync
14
14
  @sync_name
15
15
  @watch_thread
16
16
  @local_server_pid
17
- UNISON_CONTAINER_PORT = '5000'
17
+ UNISON_CONTAINER_PORT = '5000'.freeze
18
18
  def initialize(sync_name, options)
19
19
  @options = options
20
20
  @sync_name = sync_name
21
21
  # if a custom image is set, apply it
22
- if @options.key?('image')
23
- @docker_image = @options['image']
24
- else
25
- @docker_image = 'eugenmayer/unison:2.51.2.2'
26
- end
22
+ @docker_image = if @options.key?('image')
23
+ @options['image']
24
+ else
25
+ 'eugenmayer/unison:2.51.3-4.12.0-AMD64'
26
+ end
27
27
  begin
28
28
  Dependencies::Unison.ensure!
29
29
  Dependencies::Unox.ensure! if Environment.mac?
@@ -61,7 +61,7 @@ module DockerSync
61
61
 
62
62
  def watch
63
63
  args = sync_options
64
- args.push("-repeat watch")
64
+ args.push('-repeat watch')
65
65
  cmd = ''
66
66
  cmd = cmd + 'ulimit -n ' + @options['max_inotify_watches'].to_s + ' && ' if @options.key?('max_inotify_watches')
67
67
  cmd = cmd + 'unison ' + args.join(' ')
@@ -77,18 +77,25 @@ module DockerSync
77
77
  say_status 'command', cmd, :white if @options['verbose']
78
78
 
79
79
  stdout, stderr, exit_status = Open3.capture3(cmd)
80
- if not exit_status.success?
81
- say_status 'error', "Error starting sync, exit code #{$?.exitstatus}", :red
80
+ if !exit_status.success?
81
+ error_msg = "Error starting sync, exit code #{$?.exitstatus}"
82
+ say_status 'error', error_msg, :red
82
83
  say_status 'message', stdout
83
84
  say_status 'message', stderr
85
+
86
+ if @options['notify_terminal']
87
+ TerminalNotifier.notify(
88
+ "#{error_msg}", :title => @sync_name, :subtitle => @options['src'], group: 'docker-sync'
89
+ )
90
+ end
84
91
  else
85
- TerminalNotifier.notify(
86
- "Synced #{@options['src']}", :title => @sync_name
87
- ) if @options['notify_terminal']
88
- say_status 'ok', "Synced #{@options['src']}", :white
89
- if @options['verbose']
90
- say_status 'output', stdout
92
+ if @options['notify_terminal'] && @options['notify_terminal'] != 'errors_only'
93
+ TerminalNotifier.notify(
94
+ "Synced #{@options['src']}", title: @sync_name, group: 'docker-sync'
95
+ )
91
96
  end
97
+ say_status 'ok', "Synced #{@options['src']}", :white
98
+ say_status 'output', stdout if @options['verbose']
92
99
  end
93
100
  end
94
101
 
@@ -96,18 +103,16 @@ module DockerSync
96
103
  expanded_ignore_strings = []
97
104
 
98
105
  exclude_type = 'Name'
99
- unless @options['sync_excludes_type'].nil?
100
- exclude_type = @options['sync_excludes_type']
101
- end
106
+ exclude_type = @options['sync_excludes_type'] unless @options['sync_excludes_type'].nil?
102
107
 
103
108
  unless @options['sync_excludes'].nil?
104
109
  expanded_ignore_strings = @options['sync_excludes'].map do |pattern|
105
- if exclude_type == 'none'
106
- # the ignore type like Name / Path are part of the pattern
107
- ignore_string = "#{pattern}"
108
- else
109
- ignore_string = "#{exclude_type} #{pattern}"
110
- end
110
+ ignore_string = if exclude_type == 'none'
111
+ # the ignore type like Name / Path are part of the pattern
112
+ pattern.to_s
113
+ else
114
+ "#{exclude_type} #{pattern}"
115
+ end
111
116
  "-ignore='#{ignore_string}'"
112
117
  end
113
118
  end
@@ -128,32 +133,33 @@ module DockerSync
128
133
  if @options.key?('sync_group') || @options.key?('sync_groupid')
129
134
  raise('Unison does not support sync_group, sync_groupid - please use rsync if you need that')
130
135
  end
131
- return args
136
+
137
+ args
132
138
  end
133
139
 
134
140
  # cares about conflict resolution
135
141
  def sync_prefer
136
142
  case @options.fetch('sync_prefer', 'default')
137
- when 'default' then "-prefer '#{@options['src']}' -copyonconflict" # thats our default, if nothing is set
138
- when 'src' then "-prefer '#{@options['src']}'"
139
- when 'dest' then "-prefer 'socket://#{@options['sync_host_ip']}:#{sync_host_port}'"
140
- else "-prefer '#{@options['sync_prefer']}'"
143
+ when 'default' then "-prefer '#{@options['src']}' -copyonconflict" # thats our default, if nothing is set
144
+ when 'src' then "-prefer '#{@options['src']}'"
145
+ when 'dest' then "-prefer 'socket://#{@options['sync_host_ip']}:#{sync_host_port}'"
146
+ else "-prefer '#{@options['sync_prefer']}'"
141
147
  end
142
148
  end
143
149
 
144
-
145
150
  def start_container
146
151
  say_status 'ok', "Starting unison for sync #{@sync_name}", :white
147
152
 
148
153
  container_name = get_container_name
149
154
  volume_name = get_volume_name
150
155
  env = {}
151
- raise 'sync_user is no longer supported, since it ise no needed, use sync_userid only please' if @options.key?('sync_user')
156
+ if @options.key?('sync_user')
157
+ raise 'sync_user is no longer supported, since it ise no needed, use sync_userid only please'
158
+ end
152
159
 
153
160
  env['UNISON_SRC'] = '-socket 5000'
154
161
  env['UNISON_DEST'] = '/app_sync'
155
162
 
156
-
157
163
  env['MONIT_ENABLE'] = 'false'
158
164
  env['MONIT_INTERVAL'] = ''
159
165
  env['MONIT_HIGH_CPU_CYCLES'] = ''
@@ -171,17 +177,19 @@ module DockerSync
171
177
  end
172
178
 
173
179
  # start unison-image in unison socket mode mode
174
- env['HOSTSYNC_ENABLE']=0
175
- env['UNISONSOCKET_ENABLE']=1
180
+ env['HOSTSYNC_ENABLE'] = 0
181
+ env['UNISONSOCKET_ENABLE'] = 1
176
182
 
177
- additional_docker_env = env.map{ |key,value| "-e #{key}=\"#{value}\"" }.join(' ')
183
+ additional_docker_env = env.map { |key, value| "-e #{key}=\"#{value}\"" }.join(' ')
178
184
  running = `docker ps --filter 'status=running' --filter 'name=#{container_name}' --format "{{.Names}}" | grep '^#{container_name}$'`
179
185
  if running == ''
180
186
  say_status 'ok', "#{container_name} container not running", :white if @options['verbose']
181
187
  exists = `docker ps --filter "status=exited" --filter "name=#{container_name}" --format "{{.Names}}" | grep '^#{container_name}$'`
182
188
  if exists == ''
183
189
  run_privileged = ''
184
- run_privileged = '--privileged' if @options.key?('max_inotify_watches') #TODO: replace by the minimum capabilities required
190
+ if @options.key?('max_inotify_watches')
191
+ run_privileged = '--privileged'
192
+ end # TODO: replace by the minimum capabilities required
185
193
  tz_expression = '-e TZ=$(basename $(dirname `readlink /etc/localtime`))/$(basename `readlink /etc/localtime`)'
186
194
  say_status 'ok', 'Starting precopy', :white if @options['verbose']
187
195
  # we just run the precopy script and remove the container
@@ -204,7 +212,7 @@ module DockerSync
204
212
  say_status 'ok', "starting initial sync of #{container_name}", :white if @options['verbose']
205
213
  # wait until container is started, then sync:
206
214
  sync_host_port = get_host_port(get_container_name, UNISON_CONTAINER_PORT)
207
- cmd = "unison -testserver #{@options['dest']} \"socket://#{@options['sync_host_ip']}:#{sync_host_port}\""
215
+ cmd = "unison -testserver #{@options['src']} \"socket://#{@options['sync_host_ip']}:#{sync_host_port}\""
208
216
  say_status 'command', cmd, :white if @options['verbose']
209
217
  attempt = 0
210
218
  max_attempt = @options['max_attempt'] || 5
@@ -212,8 +220,12 @@ module DockerSync
212
220
  # noinspection RubyUnusedLocalVariable
213
221
  stdout, stderr, exit_status = Open3.capture3(cmd)
214
222
  break if exit_status == 0
223
+
215
224
  attempt += 1
216
- raise "Failed to start unison container in time, try to increase max_attempt (currently #{max_attempt}) in your configuration. See https://github.com/EugenMayer/docker-sync/wiki/2.-Configuration for more informations" if attempt > max_attempt
225
+ if attempt > max_attempt
226
+ raise "Failed to start unison container in time, try to increase max_attempt (currently #{max_attempt}) in your configuration. See https://github.com/EugenMayer/docker-sync/wiki/2.-Configuration for more informations"
227
+ end
228
+
217
229
  sleep 1
218
230
  end
219
231
  sync
@@ -221,7 +233,7 @@ module DockerSync
221
233
  end
222
234
 
223
235
  # noinspection RubyUnusedLocalVariable
224
- def get_host_port(container_name, container_port)
236
+ def get_host_port(container_name, _container_port)
225
237
  cmd = 'docker inspect --format=\'{{(index (index .NetworkSettings.Ports "5000/tcp") 0).HostPort}}\' ' + container_name
226
238
  say_status 'command', cmd, :white if @options['verbose']
227
239
  stdout, stderr, exit_status = Open3.capture3(cmd)
@@ -230,15 +242,15 @@ module DockerSync
230
242
  say_status 'error', "Error getting mapped port, exit code #{$?.exitstatus}", :red
231
243
  say_status 'message', stderr
232
244
  end
233
- return stdout.gsub("\n",'')
245
+ stdout.gsub("\n", '')
234
246
  end
235
247
 
236
248
  def get_container_name
237
- return "#{@sync_name}"
249
+ @sync_name.to_s
238
250
  end
239
251
 
240
252
  def get_volume_name
241
- return @sync_name
253
+ @sync_name
242
254
  end
243
255
 
244
256
  def stop_container
@@ -92,9 +92,13 @@ class UpdateChecker
92
92
  if check.update_available
93
93
  say_status 'warning',"There is an update (#{check.latest_version}) available (current version #{check.current_version}). Please update before you continue",:yellow
94
94
  if yes?("Shall I update docker-sync to #{check.latest_version} for you?")
95
- system('gem update docker-sync')
96
- say_status 'success','Successfully updated, please restart docker-sync and check the changelog at https://github.com/EugenMayer/docker-sync/wiki/5.-Changelog',:green
97
- exit 0
95
+ if system('gem update docker-sync')
96
+ say_status 'success','Successfully updated, please restart docker-sync and check the changelog at https://github.com/EugenMayer/docker-sync/releases',:green
97
+ exit 0
98
+ else
99
+ say_status 'error','Unable to update docker-sync',:red
100
+ exit 1
101
+ end
98
102
  else
99
103
  exit 1 if update_enforced
100
104
  end
data/tasks/sync/sync.thor CHANGED
@@ -79,6 +79,17 @@ class Sync < Thor
79
79
 
80
80
  end
81
81
 
82
+ desc 'restart', 'Restart docker-sync daemon'
83
+ method_option :daemon, :aliases => '-d', :default => false, :type => :boolean, :desc => 'Run in the background'
84
+ method_option :foreground, :aliases => '-f', :default => false, :type => :boolean, :desc => 'Run in the foreground'
85
+ method_option :app_name, :aliases => '--name', :default => 'daemon', :type => :string, :desc => 'App name used in PID and OUTPUT file name for Daemon'
86
+ method_option :dir, :aliases => '--dir', :default => './.docker-sync', :type => :string, :desc => 'Path to PID and OUTPUT file Directory'
87
+ method_option :logd, :aliases => '--logd', :default => true, :type => :boolean, :desc => 'To log OUPUT to file on Daemon or not'
88
+ def restart
89
+ invoke :stop, options.select{|k, _| ["app_name", "dir"].include?(k) }
90
+ invoke :start
91
+ end
92
+
82
93
  desc 'sync', 'just sync - do not start a watcher though'
83
94
  def sync
84
95
  print_version if options[:version]
@@ -156,7 +167,7 @@ class Sync < Thor
156
167
  # Check to see if we're already running:
157
168
  if daemon_running?
158
169
  should_exit = true
159
- unless options[:sync_name].empty?
170
+ unless options[:sync_name].nil? || options[:sync_name].empty?
160
171
  running = `docker ps --filter 'status=running' --filter 'name=#{options[:sync_name]}' --format "{{.Names}}" | grep '^#{options[:sync_name]}$'`
161
172
  should_exit = false if running == ''
162
173
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docker-sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.13
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eugen Mayer
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-02 00:00:00.000000000 Z
11
+ date: 2021-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -16,20 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.20'
19
+ version: '1.0'
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 0.20.0
22
+ version: 1.0.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - "~>"
28
28
  - !ruby/object:Gem::Version
29
- version: '0.20'
29
+ version: '1.0'
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 0.20.0
32
+ version: 1.0.0
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: gem_update_checker
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -209,7 +209,7 @@ homepage: https://github.com/EugenMayer/docker_sync
209
209
  licenses:
210
210
  - GPL-3.0
211
211
  metadata: {}
212
- post_install_message:
212
+ post_install_message:
213
213
  rdoc_options: []
214
214
  require_paths:
215
215
  - lib
@@ -217,16 +217,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
217
217
  requirements:
218
218
  - - ">="
219
219
  - !ruby/object:Gem::Version
220
- version: '2.0'
220
+ version: '2.4'
221
221
  required_rubygems_version: !ruby/object:Gem::Requirement
222
222
  requirements:
223
223
  - - ">="
224
224
  - !ruby/object:Gem::Version
225
225
  version: '0'
226
226
  requirements: []
227
- rubyforge_project:
228
- rubygems_version: 2.6.14.3
229
- signing_key:
227
+ rubygems_version: 3.1.4
228
+ signing_key:
230
229
  specification_version: 4
231
230
  summary: Docker Sync - Fast and efficient way to sync code to docker-containers
232
231
  test_files: []