docker-sync 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 663dc1ebdf1337d31366115930e6b1cef1c341e8
4
- data.tar.gz: 603862a7b3dcbe9b34c5f1d59fafc9b55173802b
3
+ metadata.gz: 0b96d12026f794c7f137c039fb0389e8a2bd9f99
4
+ data.tar.gz: 3fdd3d6be8832db97540a5b36fffe0ba8e92c810
5
5
  SHA512:
6
- metadata.gz: f9dc34c1f10e8f4c42dfd5e54d84eee04ae913d5ec5c8630f7609762e79b14adf7463ff626f9973e24f29f877a8247709048488768927a9a5ee038958773f887
7
- data.tar.gz: b9b3e09576d94707ee2e77ce8b5125c0e76d55f2be3a506f54669860b7714e4495aee005b1d51860f0106c1ed03f6ee9daeb53fdfddfc9d8b0d4813ce2a0e510
6
+ metadata.gz: f20e0ed261406702dad8118c901157f815832261d811d839fc53f290206ce84132136f6f6c4dc7d58d2b01c0b28c689e76886326e04937b5dba9f17ab1172c7b
7
+ data.tar.gz: ea92cf7f46e23dd7b396215f6f68bdadfcbf4f6b1169d3a954820fb41ccb73466e1df6d4153704ec98f08a4b2f7f10454eda6fcbbd1f4f430a9882fde3f791da
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -135,12 +135,8 @@ module Docker_Sync
135
135
 
136
136
  # cares about conflict resolution
137
137
  def sync_prefer
138
- # thats our default, if nothing is set
139
- unless @options.key?('sync_prefer') || @options['sync_prefer'] == 'default'
140
- return "-prefer '#{@options['src']}' -copyonconflict"
141
- end
142
-
143
- case @options['sync_prefer']
138
+ case @options.fetch('sync_prefer', 'default')
139
+ when 'default' then "-prefer '#{@options['src']}' -copyonconflict" # thats our default, if nothing is set
144
140
  when 'src' then "-prefer #{@options['src']}"
145
141
  when 'dest' then "-prefer #{@options['dest']}"
146
142
  else "-prefer #{@options['sync_prefer']}"
@@ -171,14 +167,7 @@ module Docker_Sync
171
167
  if exists == ''
172
168
  say_status 'ok', "creating #{container_name} container", :white if @options['verbose']
173
169
  run_privileged = '--privileged' if @options.key?('max_inotify_watches') #TODO: replace by the minimum capabilities required
174
- cmd = "docker run -p '#{@options['sync_host_ip']}::#{UNISON_CONTAINER_PORT}' \
175
- -v #{volume_name}:#{@options['dest']} \
176
- -e VOLUME=#{@options['dest']} \
177
- -e TZ=${TZ-`readlink /etc/localtime | sed -e 's,/usr/share/zoneinfo/,,'`} \
178
- #{additional_docker_env} \
179
- #{run_privileged} \
180
- --name #{container_name} \
181
- -d #{@docker_image}"
170
+ 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}"
182
171
  else
183
172
  say_status 'ok', "starting #{container_name} container", :white if @options['verbose']
184
173
  cmd = "docker start #{container_name} && docker exec #{container_name} supervisorctl restart unison"
@@ -39,12 +39,12 @@ class Daemon < Thor
39
39
  sync.clean
40
40
  end
41
41
 
42
- desc 'log', 'Prints last 100 lines of daemon log. Only for use with docker-sync started in background.'
42
+ desc 'logs', 'Prints last 100 lines of daemon log. Only for use with docker-sync started in background.'
43
43
  method_option :lines, :aliases => '--lines', :default => 100, :type => :numeric, :desc => 'Specify number of lines to tail'
44
44
  method_option :follow, :aliases => '-f', :default => false, :type => :boolean, :desc => 'Specify if the logs should be streamed'
45
- def log
45
+ def logs
46
46
  opt = options.dup
47
47
  sync = Sync.new([], opt)
48
- sync.log
48
+ sync.logs
49
49
  end
50
50
  end
@@ -12,16 +12,20 @@ class Sync < Thor
12
12
  class_option :sync_name, :aliases => '-n',:type => :string, :desc => 'If given, only this sync configuration will be references/started/synced'
13
13
  class_option :version, :aliases => '-v',:type => :boolean, :default => false, :desc => 'prints out the version of docker-sync and exits'
14
14
 
15
+ desc '--version, -v', 'Prints out the version of docker-sync and exits'
16
+ def print_version
17
+ puts UpgradeChecker.get_current_version
18
+ exit(0)
19
+ end
20
+ map %w[--version -v] => :print_version
21
+
15
22
  desc 'start', 'Start all sync configurations in this project'
16
23
  method_option :daemon, :aliases => '-d', :default => false, :type => :boolean, :desc => 'Run in the background'
17
24
  method_option :app_name, :aliases => '--name', :default => 'daemon', :type => :string, :desc => 'App name used in PID and OUTPUT file name for Daemon'
18
25
  method_option :dir, :aliases => '--dir', :default => './.docker-sync', :type => :string, :desc => 'Path to PID and OUTPUT file Directory'
19
26
  method_option :logd, :aliases => '--logd', :default => true, :type => :boolean, :desc => 'To log OUPUT to file on Daemon or not'
20
27
  def start
21
- if options[:version]
22
- puts UpgradeChecker.get_current_version
23
- exit(0)
24
- end
28
+ print_version if options[:version]
25
29
  # do run update check in the start command only
26
30
  UpdateChecker.new().run
27
31
  UpgradeChecker.new().run
@@ -46,10 +50,7 @@ class Sync < Thor
46
50
  method_option :app_name, :aliases => '--name', :default => 'daemon', :type => :string, :desc => 'App name used in PID and OUTPUT file name for Daemon'
47
51
  method_option :dir, :aliases => '--dir', :default => './.docker-sync', :type => :string, :desc => 'Path to PID and OUTPUT file Directory'
48
52
  def stop
49
- if options[:version]
50
- puts UpgradeChecker.get_current_version
51
- exit(0)
52
- end
53
+ print_version if options[:version]
53
54
 
54
55
  config_path = config_preconditions
55
56
  sync_manager = Docker_sync::SyncManager.new(:config_path => config_path)
@@ -68,10 +69,7 @@ class Sync < Thor
68
69
 
69
70
  desc 'sync', 'just sync - do not start a watcher though'
70
71
  def sync
71
- if options[:version]
72
- puts UpgradeChecker.get_current_version
73
- exit(0)
74
- end
72
+ print_version if options[:version]
75
73
 
76
74
  config_path = config_preconditions # Preconditions and Define config_path from shared method
77
75
 
@@ -81,10 +79,7 @@ class Sync < Thor
81
79
 
82
80
  desc 'clean', 'Stop and clean up all sync endpoints'
83
81
  def clean
84
- if options[:version]
85
- puts UpgradeChecker.get_current_version
86
- exit(0)
87
- end
82
+ print_version if options[:version]
88
83
 
89
84
  config_path = config_preconditions # Preconditions and Define config_path from shared method
90
85
 
@@ -93,7 +88,7 @@ class Sync < Thor
93
88
  files = Dir[File.join(dir, '*.pid')]
94
89
  files.each do |pid_file|
95
90
  pid = File.read(pid_file).to_i
96
- Process.kill(:INT, -(Process.getpgid(pid)))
91
+ Process.kill(:INT, -(Process.getpgid(pid))) if Daemons::Pid.running?(pid)
97
92
  say_status 'shutdown', 'Background dsync has been stopped'
98
93
  end
99
94
  # Remove the .docker-sync directory
@@ -104,14 +99,14 @@ class Sync < Thor
104
99
  say_status 'success', 'Finished cleanup. Removed stopped, removed sync container and removed their volumes', :green
105
100
  end
106
101
 
107
- desc 'log', 'Prints last 100 lines of daemon log. Only for use with docker-sync started in background.'
102
+ desc 'logs', 'Prints last 100 lines of daemon log. Only for use with docker-sync started in background.'
108
103
  method_option :lines, :aliases => '--lines', :default => 100, :type => :numeric, :desc => 'Specify number of lines to tail'
109
104
  method_option :follow, :aliases => '-f', :default => false, :type => :boolean, :desc => 'Specify if the logs should be streamed'
110
- def log
111
- if options[:version]
112
- puts UpgradeChecker.get_current_version
113
- exit(0)
114
- end
105
+ method_option :dir, :aliases => '--dir', :default => './.docker-sync', :type => :string, :desc => 'Path to PID and OUTPUT file Directory'
106
+ method_option :logd, :aliases => '--logd', :default => true, :type => :boolean, :desc => 'To log OUPUT to file on Daemon or not'
107
+ method_option :app_name, :aliases => '--name', :default => 'daemon', :type => :string, :desc => 'App name used in PID and OUTPUT file name for Daemon'
108
+ def logs
109
+ print_version if options[:version]
115
110
 
116
111
  print_daemon_logs
117
112
  end
@@ -119,10 +114,7 @@ class Sync < Thor
119
114
  desc 'list', 'List all sync-points of the project configuration path'
120
115
  method_option :verbose, :default => false, :type => :boolean, :desc => 'Verbose output'
121
116
  def list
122
- if options[:version]
123
- puts UpgradeChecker.get_current_version
124
- exit(0)
125
- end
117
+ print_version if options[:version]
126
118
 
127
119
  config_path = config_preconditions # Preconditions and Define config_path from shared method
128
120
 
@@ -197,7 +189,6 @@ class Sync < Thor
197
189
 
198
190
  def daemon_running?
199
191
  pid_file = Daemons::PidFile.find_files(options['dir'], options['app_name']).first || ''
200
-
201
192
  File.file?(pid_file) && Daemons::Pid.running?(File.read(pid_file).to_i)
202
193
  end
203
194
  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.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eugen Mayer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-19 00:00:00.000000000 Z
11
+ date: 2017-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor