Skip to content

Commit

Permalink
implement showing logs in the foreground when native_osx is used, #341
Browse files Browse the repository at this point in the history
  • Loading branch information
EugenMayer committed May 5, 2017
1 parent 69fdd34 commit 0f790f9
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/docker-sync/config/project_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def default_watch_strategy(sync_config)
when 'rsync' then 'fswatch'
when 'unison' then 'unison'
when 'native' then 'dummy'
when 'native_osx' then 'dummy'
when 'native_osx' then 'remotelogs'
else raise "you shouldn't be here"
end
end
Expand Down
3 changes: 3 additions & 0 deletions lib/docker-sync/sync_process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
require 'docker-sync/watch_strategy/fswatch'
require 'docker-sync/watch_strategy/dummy'
require 'docker-sync/watch_strategy/unison'
require 'docker-sync/watch_strategy/remotelogs'

module Docker_Sync
class SyncProcess
Expand Down Expand Up @@ -62,6 +63,8 @@ def set_watch_strategy
@watch_strategy = Docker_Sync::WatchStrategy::Dummy.new(@sync_name, @options)
when 'unison'
@watch_strategy = Docker_Sync::WatchStrategy::Unison.new(@sync_name, @options)
when 'remotelogs'
@watch_strategy = Docker_Sync::WatchStrategy::Remote_logs.new(@sync_name, @options)
else
raise "Unknown watch_strategy #{@options['watch_strategy']}"
end
Expand Down
4 changes: 2 additions & 2 deletions lib/docker-sync/upgrade_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ def check_and_warn
checker = UpdateChecker.new
checker.check_unison_hostsync_image

Thor::Shell::Basic.new.say_status 'warning', "The native_osx strategy i only available for docker-for-mac now, this is due to https://github.com/EugenMayer/docker-sync/issues/346\n\nThat means, that unison is picked as a default automatically, if you use docker-machine", :red
Thor::Shell::Basic.new.say_status 'warning', "The native_osx is NOW ONLY for docker-for-mac, this is due to https://github.com/EugenMayer/docker-sync/issues/346\n\nThat means, that unison is picked as a default automatically, if you use docker-machine", :red

unless Thor::Shell::Basic.new.yes?('Just wanted you to no that? (y/N)')
unless Thor::Shell::Basic.new.yes?('Just wanted you to no that! (y/N)')
exit 1
end
end
Expand Down
50 changes: 50 additions & 0 deletions lib/docker-sync/watch_strategy/remotelogs.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
require 'thor/shell'
require 'docker-sync/execution'

module Docker_Sync
module WatchStrategy
class Remote_logs
include Thor::Shell
include Execution

@options
@sync_name
@watch_fork
@watch_thread

def initialize(sync_name, options)
@options = options
@sync_name = sync_name
@watch_fork = nil
@watch_thread = nil
@unison = Docker_Sync::SyncStrategy::Unison.new(@sync_name, @options)
end

def run
say_status 'success', "Showing unison logs from your sync container: #{@unison.get_container_name}", :green
cmd = "docker exec #{@unison.get_container_name} tail -f /tmp/unison.log"
@watch_thread = threadexec(cmd, 'Sync Log:')
end

def stop
end

def clean
end

def watch
end

def watch_options
end

def watch_fork
return @watch_fork
end

def watch_thread
return @watch_thread
end
end
end
end

0 comments on commit 0f790f9

Please sign in to comment.