zeus 0.4.6 → 0.10.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. data/Gemfile +0 -4
  2. data/Rakefile +52 -8
  3. data/bin/zeus +14 -6
  4. data/build/fsevents-wrapper +0 -0
  5. data/build/zeus-darwin-amd64 +0 -0
  6. data/build/zeus-linux-386 +0 -0
  7. data/build/zeus-linux-amd64 +0 -0
  8. data/examples/zeus.json +22 -0
  9. data/ext/fsevents-wrapper/fsevents-wrapper +0 -0
  10. data/ext/inotify-wrapper/extconf.rb +24 -0
  11. data/ext/inotify-wrapper/inotify-wrapper.cpp +86 -0
  12. data/lib/zeus.rb +123 -35
  13. data/lib/zeus/{server/load_tracking.rb → load_tracking.rb} +1 -3
  14. data/lib/zeus/rails.rb +141 -0
  15. data/man/build/zeus +49 -0
  16. data/man/build/zeus-init +13 -0
  17. data/man/build/zeus-init.txt +17 -0
  18. data/man/build/zeus-start +16 -0
  19. data/man/build/zeus-start.txt +18 -0
  20. data/man/build/zeus.txt +50 -0
  21. data/zeus.gemspec +17 -6
  22. metadata +27 -58
  23. data/.gitignore +0 -17
  24. data/.travis.yml +0 -5
  25. data/.zeus.rb +0 -11
  26. data/README.md +0 -73
  27. data/docs/acceptor_registration.md +0 -14
  28. data/docs/client_server_handshake.md +0 -25
  29. data/ext/fsevents-wrapper/main.m +0 -118
  30. data/lib/thrud.rb +0 -97
  31. data/lib/zeus/cli.rb +0 -80
  32. data/lib/zeus/client.rb +0 -114
  33. data/lib/zeus/client/winsize.rb +0 -28
  34. data/lib/zeus/error_printer.rb +0 -16
  35. data/lib/zeus/plan.rb +0 -18
  36. data/lib/zeus/plan/acceptor.rb +0 -38
  37. data/lib/zeus/plan/node.rb +0 -66
  38. data/lib/zeus/plan/stage.rb +0 -50
  39. data/lib/zeus/server.rb +0 -103
  40. data/lib/zeus/server/acceptor.rb +0 -79
  41. data/lib/zeus/server/acceptor_registration_monitor.rb +0 -75
  42. data/lib/zeus/server/client_handler.rb +0 -106
  43. data/lib/zeus/server/command_runner.rb +0 -70
  44. data/lib/zeus/server/file_monitor.rb +0 -8
  45. data/lib/zeus/server/file_monitor/fsevent.rb +0 -102
  46. data/lib/zeus/server/process_tree_monitor.rb +0 -89
  47. data/lib/zeus/server/stage.rb +0 -88
  48. data/lib/zeus/server/stage/error_state.rb +0 -42
  49. data/lib/zeus/server/stage/feature_notifier.rb +0 -38
  50. data/lib/zeus/templates/rails.rb +0 -133
  51. data/lib/zeus/ui.rb +0 -57
  52. data/lib/zeus/version.rb +0 -3
  53. data/spec/cli_spec.rb +0 -95
  54. data/spec/error_printer_spec.rb +0 -27
  55. data/spec/integration_spec.rb +0 -106
  56. data/spec/server/file_monitor/fsevent_spec.rb +0 -88
  57. data/spec/server/load_tracking_spec.rb +0 -67
  58. data/spec/server/process_tree_monitor_spec.rb +0 -50
  59. data/spec/spec_helper.rb +0 -38
  60. data/spec/ui_spec.rb +0 -54
@@ -1,88 +0,0 @@
1
- require 'socket'
2
- require 'tempfile'
3
- require 'fileutils'
4
- require 'securerandom'
5
-
6
- require 'zeus'
7
-
8
- module Zeus::Server::FileMonitor
9
- describe FSEvent do
10
-
11
- let(:fsevent) { FSEvent.new() { } }
12
-
13
- it 'registers files to be watched' do
14
- _, io_out = stub_open_wrapper!
15
-
16
- fsevent.watch("/a/b/c.rb")
17
- io_out.readline.chomp.should == "/a/b/c.rb"
18
- end
19
-
20
- it 'only registers a file with the wrapper script once' do
21
- _, io_out = stub_open_wrapper!
22
-
23
- files = ["a", "a", "b", "a", "b", "c", "d", "a"]
24
- files.each { |f| fsevent.watch(f) }
25
-
26
- files.uniq.each do |file|
27
- io_out.readline.chomp.should == file
28
- end
29
- end
30
-
31
- it 'passes changed files to a callback' do
32
- io_in, io_out = stub_open_wrapper!
33
-
34
- # to prove that very long filenames aren't truncated anywhere:
35
- filename = SecureRandom.hex(4000) + ".rb"
36
-
37
- results = []
38
- fsevent = FSEvent.new { |f| results << f }
39
-
40
- io_in.puts filename
41
- fsevent.stub(realpaths_for_givenpath: [filename])
42
- # test that the right socket is used, and it's ready for reading.
43
- IO.select([fsevent.datasource])[0].should == [io_out]
44
-
45
- Zeus.ui.should_receive(:info).with(%r{#{filename}})
46
- fsevent.on_datasource_event
47
- results[0].should == filename
48
- end
49
-
50
-
51
- it 'closes sockets not necessary in child processes' do
52
- io_in, io_out = stub_open_wrapper!
53
- fsevent.close_parent_socket
54
-
55
- io_in.should be_closed
56
- io_out.should be_closed
57
- end
58
-
59
- it 'integrates with the wrapper script to detect changes' do
60
- results = []
61
- callback = ->(path){ results << path }
62
- fsevent = FSEvent.new(&callback)
63
-
64
- file = Tempfile.new('fsevent-test')
65
-
66
- fsevent.watch(file.path)
67
-
68
- Zeus.ui.should_receive(:info).with(%r{#{file.path}})
69
-
70
- FileUtils.touch(file.path)
71
- IO.select([fsevent.datasource], [], [], 3)[0] # just wait for the data to appear
72
- fsevent.on_datasource_event
73
- results[0].should == file.path
74
-
75
- file.unlink
76
- end
77
-
78
- private
79
-
80
- def stub_open_wrapper!
81
- io_in, io_out = Socket.pair(:UNIX, :STREAM)
82
- FSEvent.any_instance.stub(open_wrapper: [io_in, io_out])
83
-
84
- [io_in, io_out]
85
- end
86
-
87
- end
88
- end
@@ -1,67 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Zeus::Server::LoadTracking do
4
- class Recorder
5
- def recorded
6
- @recorded ||= []
7
- end
8
-
9
- def add_extra_feature(*args)
10
- recorded << [:add_extra_feature, *args]
11
- end
12
- end
13
-
14
- let(:recorder){ Recorder.new }
15
-
16
- around do |example|
17
- $foo = nil
18
- Zeus::Server::LoadTracking.server = recorder
19
- example.call
20
- Zeus::Server::LoadTracking.server = nil
21
- end
22
-
23
- let(:tmp_path) { File.expand_path(Dir.pwd) }
24
-
25
- it "tracks loading of absolute paths" do
26
- write "foo.rb", "$foo = 1"
27
- load "#{Dir.pwd}/foo.rb"
28
- $foo.should == 1
29
- recorder.recorded.should == [[:add_extra_feature, tmp_path + "/foo.rb"]]
30
- end
31
-
32
- it "tracks loading of relative paths" do
33
- write "foo.rb", "$foo = 1"
34
- load "./foo.rb"
35
- $foo.should == 1
36
- recorder.recorded.should == [[:add_extra_feature, tmp_path + "/foo.rb"]]
37
- end
38
-
39
- it "tracks loading from library paths" do
40
- write "lib/foo.rb", "$foo = 1"
41
- restoring $LOAD_PATH do
42
- $LOAD_PATH << File.expand_path("lib")
43
- load "foo.rb"
44
- end
45
- $foo.should == 1
46
- recorder.recorded.should == [[:add_extra_feature, tmp_path + "/lib/foo.rb"]]
47
- end
48
-
49
- it "does not add unfound files" do
50
- write "lib/foo.rb", "$foo = 1"
51
- begin
52
- load "foo.rb"
53
- rescue LoadError
54
- end
55
- $foo.should == nil
56
- recorder.recorded.should == []
57
- end
58
-
59
- private
60
-
61
- def restoring(thingy)
62
- old = thingy.dup
63
- yield
64
- ensure
65
- thingy.replace(old)
66
- end
67
- end
@@ -1,50 +0,0 @@
1
- require 'spec_helper'
2
-
3
- class Zeus::Server
4
- describe ProcessTreeMonitor do
5
-
6
- let(:file_monitor) { stub }
7
- let(:tree) { stub }
8
- let(:monitor) { ProcessTreeMonitor.new(file_monitor, tree) }
9
-
10
- it "closes sockets not useful to forked processes" do
11
- parent, child = stub, stub
12
- ProcessTreeMonitor.any_instance.stub(open_socketpair: [parent, child])
13
- parent.should_receive(:close)
14
- monitor.close_parent_socket
15
- end
16
-
17
- it "closes sockets not useful to the master process" do
18
- parent, child = stub, stub
19
- ProcessTreeMonitor.any_instance.stub(open_socketpair: [parent, child])
20
- child.should_receive(:close)
21
- monitor.close_child_socket
22
- end
23
-
24
- it "kills nodes with a feature that changed" do
25
- tree.should_receive(:kill_nodes_with_feature).with("rails")
26
- monitor.kill_nodes_with_feature("rails")
27
- end
28
-
29
- it "passes process inheritance information to the tree" do
30
- IO.select([monitor.datasource], [], [], 0).should be_nil
31
- monitor.__CHILD__stage_starting_with_pid(:name, 1)
32
- IO.select([monitor.datasource], [], [], 0.5).should_not be_nil
33
- tree.should_receive(:stage_has_pid).with(:name, 1)
34
- monitor.on_datasource_event
35
- end
36
-
37
- it "passes process feature information to the tree" do
38
- IO.select([monitor.datasource], [], [], 0).should be_nil
39
- monitor.__CHILD__stage_has_feature(:name, "rails")
40
- IO.select([monitor.datasource], [], [], 0.5).should_not be_nil
41
- tree.should_receive(:stage_has_feature).with(:name, "rails")
42
- file_monitor.should_receive(:watch).with("rails")
43
- monitor.on_datasource_event
44
- end
45
-
46
- private
47
-
48
- end
49
- end
50
-
@@ -1,38 +0,0 @@
1
- require 'zeus'
2
-
3
- module FolderHelpers
4
- def write(file, content)
5
- ensure_folder File.dirname(file)
6
- File.open(file, 'w'){|f| f.write content }
7
- end
8
-
9
- def read(file)
10
- File.read file
11
- end
12
-
13
- def delete(file)
14
- `rm #{file}`
15
- end
16
-
17
- def ensure_folder(folder)
18
- `mkdir -p #{folder}` unless File.exist?(folder)
19
- end
20
-
21
- def root
22
- File.expand_path '../..', __FILE__
23
- end
24
- end
25
-
26
- RSpec.configure do |config|
27
- config.include FolderHelpers
28
-
29
- config.around do |example|
30
- folder = File.expand_path("../tmp", __FILE__)
31
- `rm -rf #{folder}`
32
- ensure_folder folder
33
- Dir.chdir folder do
34
- example.call
35
- end
36
- `rm -rf #{folder}`
37
- end
38
- end
@@ -1,54 +0,0 @@
1
- require 'zeus'
2
-
3
- module Zeus
4
- describe UI do
5
-
6
- let(:ui) {
7
- ui = UI.new
8
- # override this method to return the result rather than printing it.
9
- def ui.tell_me(msg, color)
10
- return make_message(msg, color)
11
- end
12
- ui
13
- }
14
-
15
- it "prints errors in red, regardless of verbosity level" do
16
- ui.error("error").should == "\x1b[31merror\x1b[0m\n"
17
- ui.be_quiet!
18
- ui.error("error").should == "\x1b[31merror\x1b[0m\n"
19
- end
20
-
21
- it "prints warnings in yellow, regardless of verbosity level" do
22
- ui.warn("warning").should == "\x1b[33mwarning\x1b[0m\n"
23
- ui.be_quiet!
24
- ui.warn("warning").should == "\x1b[33mwarning\x1b[0m\n"
25
- end
26
-
27
- it "prints info messages in magenta, but not if quiet-mode is set" do
28
- ui.info("info").should == "\x1b[35minfo\x1b[0m\n"
29
- ui.be_quiet!
30
- ui.info("info").should == nil
31
- end
32
-
33
- it "doesn't print debug messages by default" do
34
- ui.debug("debug").should == nil
35
- end
36
-
37
- it "prints debug messages if debug-mode is set" do
38
- ui.debug!
39
- ui.debug("debug").should == "debug\n"
40
- end
41
-
42
- it "sets debug if ENV['DEBUG']" do
43
- ENV['DEBUG'] = "yup"
44
- ui.debug?.should be_true
45
- end
46
-
47
- it "doesn't print debug messages if both quiet-mode and debug-mode are set" do
48
- ui.be_quiet!
49
- ui.debug!
50
- ui.debug("debug").should == nil
51
- end
52
-
53
- end
54
- end