Skip to content

Commit

Permalink
merge fsevents_to_vm into dinghy
Browse files Browse the repository at this point in the history
No more installing it via rubygems on-demand, instead we now use submodules
like we do for thor. This still isn't 100% ideal, installing things like
net-ssh and rb-fsevent via submodules, but it should cause less problems than
messing with the system-installed rubygems.

This was made much easier because rb-fsevent now ships with a pre-built binary,
it doesn't compile the C module on gem install anymore.
  • Loading branch information
codekitchen committed Nov 17, 2017
1 parent 2bb5cc5 commit 005e800
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 23 deletions.
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,12 @@
[submodule "cli/daemons"]
path = cli/daemons
url = https://github.com/thuehlinger/daemons.git
[submodule "cli/rb-fsevent"]
path = cli/rb-fsevent
url = https://github.com/thibaudgg/rb-fsevent.git
[submodule "cli/net-ssh"]
path = cli/net-ssh
url = https://github.com/net-ssh/net-ssh.git
[submodule "cli/fsevents_to_vm"]
path = cli/fsevents_to_vm
url = https://github.com/codekitchen/fsevents_to_vm.git
2 changes: 1 addition & 1 deletion cli/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def http_proxy
end

def fsevents
FseventsToVm.new(machine)
FseventsToVmRunner.new(machine)
end

def start_services
Expand Down
34 changes: 12 additions & 22 deletions cli/dinghy/fsevents_to_vm.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
require 'dinghy/daemon'

class FseventsToVm
class FseventsToVmRunner
include Dinghy::Daemon
INSTALL_PATH = Dinghy.brew+"bin"
BIN_PATH = INSTALL_PATH+"fsevents_to_vm"
VERSION = "~> 1.1.3"

attr_reader :machine

Expand All @@ -13,39 +10,32 @@ def initialize(machine)
end

def up
install_if_necessary!
increase_inotify_limit
super
end

def plist_name
"dinghy.fsevents_to_vm.plist"
end

def name
"FsEvents"
end

protected

def install_if_necessary!
%x{/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/gem list --config-file '' -i -v '#{VERSION}' fsevents_to_vm}
return if $?.success? and File.exists? BIN_PATH
puts "Installing fsevents_to_vm, this will require sudo"
system!("installing", "sudo", "-H", "/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/gem", "install", "--no-rdoc", "--no-ri", "-n", INSTALL_PATH, "fsevents_to_vm", "-v", VERSION)
end

def increase_inotify_limit
machine.ssh("echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf > /dev/null")
machine.ssh("sudo sysctl -p > /dev/null")
end

def command
%W[
#{BIN_PATH}
start
--ssh-identity-file=#{machine.ssh_identity_file_path}
--ssh-ip=#{machine.vm_ip}
def run
$LOAD_PATH << File.expand_path(File.dirname(__FILE__)+"/../net-ssh/lib")
$LOAD_PATH << File.expand_path(File.dirname(__FILE__)+"/../rb-fsevent/lib")
$LOAD_PATH << File.expand_path(File.dirname(__FILE__)+"/../fsevents_to_vm/lib")
require 'fsevents_to_vm/cli'
args = [
'start',
"--ssh-identity-file=#{machine.ssh_identity_file_path}",
"--ssh-ip=#{machine.vm_ip}"
]
$0 = 'fsevents_to_vm'
FseventsToVm::Cli.start(args)
end
end
1 change: 1 addition & 0 deletions cli/fsevents_to_vm
Submodule fsevents_to_vm added at 034df7
1 change: 1 addition & 0 deletions cli/net-ssh
Submodule net-ssh added at 479074
1 change: 1 addition & 0 deletions cli/rb-fsevent
Submodule rb-fsevent added at d1153f

0 comments on commit 005e800

Please sign in to comment.