invoker 1.5.3 → 1.5.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +5 -5
  2. data/lib/invoker.rb +5 -6
  3. data/lib/invoker/cli.rb +47 -14
  4. data/lib/invoker/command_worker.rb +6 -2
  5. data/lib/invoker/commander.rb +8 -2
  6. data/lib/invoker/ipc/unix_client.rb +2 -2
  7. data/lib/invoker/parsers/config.rb +3 -3
  8. data/lib/invoker/power/balancer.rb +6 -4
  9. data/lib/invoker/power/setup.rb +9 -6
  10. data/lib/invoker/power/setup/distro/base.rb +36 -13
  11. data/lib/invoker/power/setup/distro/ubuntu.rb +36 -0
  12. data/lib/invoker/power/setup/linux_setup.rb +11 -19
  13. data/lib/invoker/power/setup/osx_setup.rb +4 -4
  14. data/lib/invoker/process_manager.rb +7 -4
  15. data/lib/invoker/process_printer.rb +16 -0
  16. data/lib/invoker/reactor/reader.rb +17 -6
  17. data/lib/invoker/version.rb +1 -1
  18. data/spec/invoker/config_spec.rb +4 -4
  19. data/spec/invoker/power/balancer_spec.rb +31 -0
  20. data/spec/invoker/power/setup/linux_setup_spec.rb +97 -34
  21. data/spec/invoker/power/url_rewriter_spec.rb +24 -25
  22. data/spec/spec_helper.rb +3 -3
  23. metadata +56 -69
  24. data/.coveralls.yml +0 -1
  25. data/.gitignore +0 -16
  26. data/.rspec +0 -2
  27. data/.rubocop.yml +0 -29
  28. data/.travis.yml +0 -10
  29. data/Dockerfile +0 -7
  30. data/Gemfile +0 -13
  31. data/MIT-LICENSE +0 -20
  32. data/Rakefile +0 -15
  33. data/TODO +0 -5
  34. data/contrib/completion/invoker-completion.bash +0 -70
  35. data/contrib/completion/invoker-completion.zsh +0 -62
  36. data/examples/hello_sinatra.rb +0 -26
  37. data/examples/sample.ini +0 -3
  38. data/invoker.gemspec +0 -43
  39. data/lib/invoker/power/pf_migrate.rb +0 -64
  40. data/lib/invoker/power/setup/distro/mint.rb +0 -10
  41. data/readme.md +0 -25
  42. data/spec/invoker/power/pf_migrate_spec.rb +0 -87
data/Rakefile DELETED
@@ -1,15 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new
5
-
6
- task :default => :spec
7
- task :test => :spec
8
-
9
- current_directory = File.expand_path(File.dirname(__FILE__))
10
-
11
- desc "run specs inside docker"
12
- task :docker_spec do
13
- system("docker build -t invoker-ruby . ")
14
- system("docker run --name invoker-rspec --rm -v #{current_directory}:/invoker -t invoker-ruby")
15
- end
data/TODO DELETED
@@ -1,5 +0,0 @@
1
- Todos for current release
2
-
3
- * Implement port support via config file
4
- * Fix setup command and make it eaiser for people who have pow configured.
5
- * Possibly add support for foreman?
@@ -1,70 +0,0 @@
1
- # BASH completion function for Invoker
2
-
3
- # source it from bashrc
4
- # dependencies:
5
- # 1) netcat
6
- # 2) find
7
-
8
- check_open_port()
9
- {
10
- local port=$1
11
- if [[ $(which nc) ]]; then
12
- local open=$(nc -z -w2 localhost $port > /dev/null; echo $?)
13
- if [[ "$open" == "1" ]]; then
14
- COMPREPLY=( $(compgen -W "${port}" -- ${cur}) )
15
- else
16
- check_open_port $(($port+1))
17
- fi
18
- fi
19
- }
20
- _invoker()
21
- {
22
- local cur prev opts
23
- COMPREPLY=()
24
- cur="${COMP_WORDS[COMP_CWORD]}"
25
- prev="${COMP_WORDS[COMP_CWORD-1]}"
26
- opts="add add_http help list reload remove setup"
27
- opts="$opts start stop tail uninstall version"
28
-
29
- case "${prev}" in
30
- add | add_http | list | reload | remove | setup | stop | tail \
31
- | uninstall | version)
32
- COMPREPLY=()
33
- ;;
34
- -d | --daemon | --no-daemon)
35
- local extra_opts=("--port")
36
- COMPREPLY=( $(compgen -W "${extra_opts}" -- ${cur}) )
37
- ;;
38
- --port)
39
- # auto-suggest port
40
- check_open_port 9000
41
- ;;
42
- help)
43
- # Show opts again, but only once; don't infinitely recurse
44
- local prev2="${COMP_WORDS[COMP_CWORD-2]}"
45
- if [ "$prev2" == "help" ]; then
46
- COMPREPLY=()
47
- else
48
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
49
- fi
50
- ;;
51
- start)
52
- local filename=$(find . -type f -name "*.ini")
53
- if [[ $filename ]]; then
54
- COMPREPLY=( $(compgen -W "${filename}" -- ${cur}) )
55
- else
56
- COMPREPLY=()
57
- fi
58
- ;;
59
- *.ini)
60
- local start_opts="-d --daemon --no-daemon --port"
61
- COMPREPLY=( $(compgen -W "${start_opts}" -- ${cur}) )
62
- ;;
63
- invoker)
64
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
65
- ;;
66
- esac
67
-
68
- return 0
69
- }
70
- complete -F _invoker invoker
@@ -1,62 +0,0 @@
1
- #compdef invoker
2
-
3
- # ZSH completion function for Invoker
4
- #
5
- # Drop this file somewhere in your $fpath
6
- # and rename it _invoker
7
- #
8
- # The recommended way to install this script is to copy to '~/.zsh/_invoker'
9
- # and then add the following to your ~/.zshrc file:
10
- #
11
- # fpath=(~/.zsh $fpath)
12
- #
13
- # You may also need to force rebuild 'zcompdump':
14
- #
15
- # rm -f ~/.zcompdump*; compinit
16
-
17
- local curcontext="$curcontext" state line ret=1
18
-
19
- _arguments -C \
20
- '1: :->cmds' \
21
- '*:: :->args' && ret=0
22
-
23
- case $state in
24
- cmds)
25
- _values 'invoker command' \
26
- 'add[Add a program to Invoker server]' \
27
- 'add_http[Add an external process to Invoker DNS server]' \
28
- 'help[Describe available commands or one specific command]' \
29
- 'list[List all running processes]' \
30
- 'reload[Reload a process managed by Invoker]' \
31
- 'remove[Stop a process managed by Invoker]' \
32
- 'setup[Run Invoker setup]' \
33
- 'start[Start Invoker server]' \
34
- 'stop[Stop Invoker daemon]' \
35
- 'tail[Tail a particular process]' \
36
- 'uninstall[Uninstall Invoker and all installed files]' \
37
- 'version[Print Invoker version]'
38
- ret=0
39
- ;;
40
-
41
- args)
42
- case $line[1] in
43
- help)
44
- if (( CURRENT == 2 )); then
45
- _values 'commands' \
46
- 'add' 'add_http' 'list' 'reload' 'remove' 'setup' 'start' 'stop' 'tail' 'uninstall' 'version'
47
- fi
48
- ret=0
49
- ;;
50
-
51
- start)
52
- _arguments \
53
- '(-d --daemon)'{-d,--daemon}'[Daemonize the server into the background]' \
54
- '(--port)--port[Port series to be used for starting rack servers]' \
55
- '1:config file:_path_files'
56
- ret=0
57
- ;;
58
- esac
59
- ;;
60
- esac
61
-
62
- return ret
@@ -1,26 +0,0 @@
1
- # myapp.rb
2
- require 'sinatra'
3
-
4
- get '/' do
5
- 'Hello world!'
6
- end
7
-
8
- get "/emacs" do
9
- redirect to("/vim")
10
- end
11
-
12
- get "/vim" do
13
- "vim rules"
14
- end
15
-
16
-
17
- post '/foo' do
18
- puts request.env
19
- "done"
20
- end
21
-
22
-
23
- post "/api/v1/datapoints" do
24
- puts request.env
25
- "done"
26
- end
data/examples/sample.ini DELETED
@@ -1,3 +0,0 @@
1
- [rails]
2
- directory = ./examples
3
- command = ruby hello_sinatra.rb -p $PORT
data/invoker.gemspec DELETED
@@ -1,43 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- GEM_NAME = "invoker"
4
-
5
- lib = File.expand_path("../lib", __FILE__)
6
- $: << lib unless $:.include?(lib)
7
-
8
- require "invoker/version"
9
-
10
- Gem::Specification.new do |s|
11
- s.name = GEM_NAME
12
- s.version = Invoker::VERSION
13
-
14
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
15
- s.authors = ["Hemant Kumar", "Amitava Basak"]
16
- s.description = %q{Something small for process management}
17
- s.email = %q{hemant@codemancers.com}
18
-
19
- s.files = `git ls-files`.split("\n")
20
- s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
21
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
22
- s.require_paths = ["lib"]
23
-
24
- s.homepage = %q{http://invoker.codemancers.com}
25
- s.licenses = ["MIT"]
26
- s.require_paths = ["lib"]
27
- s.summary = %q{Something small for Process management}
28
- s.add_dependency("thor", "~> 0.19")
29
- s.add_dependency("rainbow", "~> 2.1.0")
30
- s.add_dependency("iniparse", "~> 1.1")
31
- s.add_dependency("formatador", "~> 0.2")
32
- s.add_dependency("eventmachine", "~> 1.0.4")
33
- s.add_dependency("em-proxy", "~> 0.1")
34
- s.add_dependency("rubydns", "~> 0.8.5")
35
- s.add_dependency("uuid", "~> 2.3")
36
- s.add_dependency("facter", "~> 2.2")
37
- s.add_dependency("http-parser-lite", "~> 0.6")
38
- s.add_dependency("dotenv", "~> 2.0")
39
- s.add_development_dependency("rspec", "~> 3.0")
40
- s.add_development_dependency("mocha")
41
- s.add_development_dependency("rake")
42
- s.add_development_dependency('fakefs')
43
- end
@@ -1,64 +0,0 @@
1
- module Invoker
2
- module Power
3
- # for migrating existins users to pf
4
- class PfMigrate
5
- def firewall_config_requires_migration?
6
- return false if !Invoker.darwin?
7
- # lets not migrate on osx < 10.10
8
- return false if osx_version < Invoker::Version.new("14.0.0")
9
- # also verify if firewall config is old
10
- check_firewall_file?
11
- end
12
-
13
- def migrate
14
- if firewall_config_requires_migration? && ask_user_for_migration
15
- sudome
16
- osx_setup = Invoker::Power::OsxSetup.new(Invoker.config.tld)
17
- osx_setup.install_firewall(Invoker.config.http_port, Invoker.config.https_port)
18
- drop_to_normal_user
19
- Invoker::Logger.puts "Invoker has updated its configuration for yosemite."\
20
- " Please restart OSX to complete the configuration process.".color(:red)
21
- exit(-1)
22
- end
23
- end
24
-
25
- def ask_user_for_migration
26
- if not_already_root?
27
- Invoker::Logger.puts "Invoker has detected you are running OSX 10.10 "\
28
- " but your invoker configuration does not support it."
29
- Invoker::Logger.puts "Invoker can update its configuration automaticaly"\
30
- " but it will require a system reboot.".color(:red)
31
- Invoker::CLI::Question.agree("Update Invoker configuration (y/n) :")
32
- else
33
- true
34
- end
35
- end
36
-
37
- # http://jimeh.me/blog/2010/02/22/built-in-sudo-for-ruby-command-line-tools/
38
- def sudome
39
- if not_already_root?
40
- exec("sudo #{$0} #{ARGV.join(' ')}")
41
- end
42
- end
43
-
44
- def not_already_root?
45
- ENV["USER"] != "root"
46
- end
47
-
48
- def drop_to_normal_user
49
- EventMachine.set_effective_user(ENV["SUDO_USER"])
50
- end
51
-
52
- def osx_version
53
- osx_kernel_version = `uname -r`.strip
54
- Invoker::Version.new(osx_kernel_version)
55
- end
56
-
57
- def check_firewall_file?
58
- return false unless File.exist?(Invoker::Power::OsxSetup::FIREWALL_PLIST_FILE)
59
- firewall_contents = File.read(Invoker::Power::OsxSetup::FIREWALL_PLIST_FILE)
60
- !!firewall_contents.match(/ipfw/)
61
- end
62
- end
63
- end
64
- end
@@ -1,10 +0,0 @@
1
- require "invoker/power/setup/distro/ubuntu"
2
-
3
- module Invoker
4
- module Power
5
- module Distro
6
- class Mint < Ubuntu
7
- end
8
- end
9
- end
10
- end
data/readme.md DELETED
@@ -1,25 +0,0 @@
1
- Invoker is a gem for managing processes in development environment.
2
-
3
- [![Build Status](https://travis-ci.org/code-mancers/invoker.svg)](https://travis-ci.org/code-mancers/invoker)
4
- [![Code Climate](https://codeclimate.com/github/code-mancers/invoker.svg)](https://codeclimate.com/github/code-mancers/invoker)
5
- [![Coverage Status](https://coveralls.io/repos/code-mancers/invoker/badge.svg)](https://coveralls.io/r/code-mancers/invoker)
6
- [![Dependency Status](https://gemnasium.com/code-mancers/invoker.svg)](https://gemnasium.com/code-mancers/invoker)
7
-
8
- ## Usage ##
9
-
10
- First we need to install `invoker` gem to get command line utility called `invoker`, we can do that via:
11
-
12
- gem install invoker
13
-
14
- Currently it only works with Ruby 1.9.3, 2.0 and 2.1.
15
-
16
- ## Manual ##
17
-
18
- Information about configuring and using Invoker can be found on - [Invoker Website](http://invoker.codemancers.com)
19
-
20
- Invoker documentation is maintained via `Jekyll` and hosted on `github`. If you would like to fix an error
21
- or update something - please submit a pull request against `gh-pages` branch of `Invoker`.
22
-
23
- ## Bug reports and Feature requests
24
-
25
- Please use [Github Issue Tracker](https://github.com/code-mancers/invoker/issues) for feature requests or bug reports.
@@ -1,87 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Invoker::Power::PfMigrate do
4
- before do
5
- FileUtils.mkdir_p("/tmp/.invoker")
6
- @old_firewall_file = Invoker::Power::OsxSetup::FIREWALL_PLIST_FILE
7
- Invoker::Power::OsxSetup.const_set(:FIREWALL_PLIST_FILE, "/tmp/.invoker/firewall")
8
- end
9
-
10
- after do
11
- Invoker::Power::OsxSetup.const_set(:FIREWALL_PLIST_FILE, @old_firewall_file)
12
- end
13
-
14
- let(:pf_migrator) { Invoker::Power::PfMigrate.new }
15
-
16
- describe "#firewall_config_requires_migration?" do
17
- context "for nonosx systems " do
18
- it "should return false" do
19
- Invoker.expects(:darwin?).returns(false)
20
- expect(pf_migrator.firewall_config_requires_migration?).to eq(false)
21
- end
22
- end
23
-
24
- context "for osx systems" do
25
- before { Invoker.expects(:darwin?).returns(true) }
26
-
27
- context "for osx < yosemite" do
28
- it "should return false" do
29
- pf_migrator.expects(:osx_version).returns(Invoker::Version.new("13.4.0"))
30
- expect(pf_migrator.firewall_config_requires_migration?).to eq(false)
31
- end
32
- end
33
-
34
- context "for osx > yosemite with existing ipfw rule" do
35
- before do
36
- write_to_firewall_file("ipfw firewall rule")
37
- end
38
- it "should return true" do
39
- pf_migrator.expects(:osx_version).returns(Invoker::Version.new("14.0.0"))
40
- expect(pf_migrator.firewall_config_requires_migration?).to eql(true)
41
- end
42
- end
43
-
44
- context "for osx >= yosemite with no ipfw rule" do
45
- before do
46
- write_to_firewall_file("rdr pass on")
47
- end
48
- it "should return false" do
49
- pf_migrator.expects(:osx_version).returns(Invoker::Version.new("14.0.0"))
50
- expect(pf_migrator.firewall_config_requires_migration?).to eql(false)
51
- end
52
- end
53
- end
54
- end
55
-
56
- describe "#migrate" do
57
- before do
58
- @original_invoker_config = Invoker.config
59
- mock_config = mock()
60
- mock_config.stubs(:http_port).returns(80)
61
- mock_config.stubs(:https_port).returns(443)
62
- mock_config.stubs(:tld).returns('dev')
63
- Invoker.config = mock_config
64
- end
65
-
66
- after do
67
- Invoker.config = @original_invoker_config
68
- end
69
-
70
- it "should migrate firewall to new system" do
71
- pf_migrator.expects(:firewall_config_requires_migration?).returns(true)
72
- pf_migrator.expects(:ask_user_for_migration).returns(true)
73
- pf_migrator.expects(:sudome)
74
- pf_migrator.expects(:drop_to_normal_user)
75
- pf_migrator.expects(:exit)
76
-
77
- pf_migrator.migrate
78
- expect(pf_migrator.check_firewall_file?).to eql(false)
79
- end
80
- end
81
-
82
- def write_to_firewall_file(content)
83
- File.open(Invoker::Power::OsxSetup::FIREWALL_PLIST_FILE, "w") do |fl|
84
- fl.write(content)
85
- end
86
- end
87
- end