soaring 0.1.10 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -0
- data/README.md +7 -2
- data/bin/soaring +1 -1
- data/lib/soaring/cli.rb +34 -67
- data/lib/soaring/initializer.rb +11 -15
- data/lib/soaring/packager.rb +23 -9
- data/lib/soaring/runner.rb +3 -8
- data/lib/soaring/tools.rb +18 -0
- data/lib/soaring/version.rb +1 -1
- data/lib/soaring.rb +1 -0
- data/soaring.gemspec +2 -0
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a12653a876a7027f53549f4a67afad4fe70ecbc
|
4
|
+
data.tar.gz: 2494d103023713962850494cbc297d3721dcd958
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3903c7eab3cdd2475f9b8cf32b6c57b5dc1a5434e39674c107a7ea635be34040ea5b474e23c2440eb3f630d325bbf3ac574cc12362e32491f4905994c8918614
|
7
|
+
data.tar.gz: e9f941396a3bef6f5edfaed144d2bb5065d8c4729509c903aafd053b38a34347405c5de844fb431e5df60ba03af86e5c20e7fff481ebf4931746c1ee093b5602
|
data/Gemfile
ADDED
data/README.md
CHANGED
@@ -36,7 +36,7 @@ Create an environment.yml file by copying the example and updating to your needs
|
|
36
36
|
|
37
37
|
Start up a local instance of the service component to check that all is well
|
38
38
|
```bash
|
39
|
-
soaring
|
39
|
+
soaring start
|
40
40
|
```
|
41
41
|
|
42
42
|
This will default to a MRI ruby rack application running with the following defaults:
|
@@ -45,9 +45,14 @@ This will default to a MRI ruby rack application running with the following defa
|
|
45
45
|
environment = 'development'
|
46
46
|
```
|
47
47
|
|
48
|
+
To stop you can simply send a CTRL-C or programmatically kill it using the stop command from another terminal
|
49
|
+
```bash
|
50
|
+
soaring stop
|
51
|
+
```
|
52
|
+
|
48
53
|
These defaults can be overriden using parameters passed to soaring. View the command line options:
|
49
54
|
```bash
|
50
|
-
soaring
|
55
|
+
soaring help
|
51
56
|
```
|
52
57
|
|
53
58
|
## Packaging the service component for deployment
|
data/bin/soaring
CHANGED
data/lib/soaring/cli.rb
CHANGED
@@ -1,82 +1,49 @@
|
|
1
|
-
require '
|
1
|
+
require 'thor'
|
2
2
|
|
3
3
|
module Soaring
|
4
|
-
class
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
class SoaringCLI < Thor
|
5
|
+
desc "init [OPTIONS]", "initialize the folder with soar_sc template"
|
6
|
+
option :verbose, :aliases => '-v', :desc => 'Verbose logging'
|
7
|
+
option :project_root, :default => Dir.pwd, :desc => 'Root folder of the soar project, defaults to current folder'
|
8
|
+
option :soar_sc_refspec, :aliases => '-r', :default => 'STABLE', :desc => 'Reference spec (Tag) of soar_sc repo to use for template, defaults to STABLE'
|
9
|
+
def init
|
10
|
+
initializer = Initializer.new(options)
|
11
|
+
initializer.initialize_project
|
10
12
|
end
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
-
|
14
|
+
desc "update [OPTIONS]", "update the folder with soar_sc template"
|
15
|
+
option :verbose, :aliases => '-v', :desc => 'Verbose logging'
|
16
|
+
option :project_root, :default => Dir.pwd, :desc => 'Root folder of the soar project, defaults to current folder'
|
17
|
+
option :soar_sc_refspec, :aliases => '-r', :default => 'STABLE', :desc => 'Reference spec (Tag) of soar_sc repo to use for template, defaults to STABLE'
|
18
|
+
def update
|
15
19
|
initializer = Initializer.new(options)
|
16
|
-
initializer.initialize_project
|
20
|
+
initializer.initialize_project
|
17
21
|
end
|
18
22
|
|
19
|
-
|
23
|
+
desc "start [OPTIONS]", "start the service component with OPTIONS"
|
24
|
+
option :verbose, :aliases => '-v', :desc => 'Verbose logging'
|
25
|
+
option :project_root, :default => Dir.pwd, :desc => 'Root folder of the soar project, defaults to current folder'
|
26
|
+
option :environment, :aliases => '-e', :default => 'development', :desc => 'Environment in which to execute [development,production]'
|
27
|
+
option :port, :aliases => '-p', :default => '9393', :desc => 'Bind service component server to this port for local run, defaults to 9393'
|
28
|
+
def start
|
20
29
|
runner = Runner.new(options)
|
21
|
-
runner.run
|
30
|
+
runner.run
|
22
31
|
end
|
23
32
|
|
24
|
-
|
25
|
-
|
26
|
-
|
33
|
+
desc "stop [OPTIONS]", "stop running rackup instances"
|
34
|
+
option :verbose, :aliases => '-v', :desc => 'Verbose logging'
|
35
|
+
option :killsignal, :aliases => '-k', :default => '9', :desc => 'The signal to send rackup instances INT signal is graceful, defaults to 9 which is not,'
|
36
|
+
def stop
|
37
|
+
exec("for f in $(ps aux | grep rackup | grep -v grep | tr -s ' ' ' ' | cut -d ' ' -f2); do echo killed $f; kill -#{options[:killsignal]} $f; done")
|
27
38
|
end
|
28
39
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
opt.separator ""
|
37
|
-
opt.separator "Commands"
|
38
|
-
opt.separator " init: create/update a new soar service component in the current folder"
|
39
|
-
opt.separator " run: run soar service locally"
|
40
|
-
opt.separator " package: package the service component for deployment"
|
41
|
-
opt.separator ""
|
42
|
-
opt.separator "Options"
|
43
|
-
|
44
|
-
opt.on("-v","--verbose","more verbose output of the process") do
|
45
|
-
options[:verbose] = true
|
46
|
-
end
|
47
|
-
|
48
|
-
opt.on("-e","--environment ENVIRONMENT","environment you want the service to run in") do |environment|
|
49
|
-
options[:environment] = environment
|
50
|
-
end
|
51
|
-
|
52
|
-
opt.on("-p","--port PORT","port to which the service component run must bind to") do |port|
|
53
|
-
options[:port] = port
|
54
|
-
end
|
55
|
-
|
56
|
-
opt.on("-r","--soar_sc_refspec REF_SPEC","git reference spec for the soar_sc to base your init on") do |soar_sc_refspec|
|
57
|
-
options[:soar_sc_refspec] = soar_sc_refspec
|
58
|
-
end
|
59
|
-
|
60
|
-
opt.on("-i","--ignore_git_checks","ignore checks ensuring your repo is up to date") do
|
61
|
-
options[:ignore_git_checks] = true
|
62
|
-
puts "Warning: Ignoring git repo checks"
|
63
|
-
end
|
64
|
-
|
65
|
-
opt.on("-h","--help","help") do
|
66
|
-
puts opt_parser
|
67
|
-
exit 0
|
68
|
-
end
|
69
|
-
end
|
70
|
-
opt_parser.parse!
|
71
|
-
|
72
|
-
command = ARGV[0]
|
73
|
-
valid_commands = ['init', 'run', 'package']
|
74
|
-
if not valid_commands.include?(command)
|
75
|
-
puts 'Invalid command'
|
76
|
-
puts opt_parser
|
77
|
-
exit 1
|
78
|
-
end
|
79
|
-
[command, options]
|
40
|
+
desc "package [OPTIONS]", "package the service component for deployment with OPTIONS"
|
41
|
+
option :verbose, :aliases => '-v', :desc => 'Verbose logging'
|
42
|
+
option :project_root, :default => Dir.pwd, :desc => 'Root folder of the soar project, defaults to current folder'
|
43
|
+
option :ignore_git_checks, :aliases => '-i', :desc => 'Ignore git check to ensure local git repo is committed, defaults to false'
|
44
|
+
def package
|
45
|
+
packager = Packager.new(options)
|
46
|
+
packager.package
|
80
47
|
end
|
81
48
|
end
|
82
49
|
end
|
data/lib/soaring/initializer.rb
CHANGED
@@ -4,25 +4,21 @@ module Soaring
|
|
4
4
|
@options = options
|
5
5
|
end
|
6
6
|
|
7
|
-
def initialize_project
|
8
|
-
@project_folder = project_folder
|
9
|
-
git_refspec = 'STABLE' #default to STABLE if not specified
|
10
|
-
git_refspec = @options[:soar_sc_refspec] if @options[:soar_sc_refspec]
|
11
|
-
|
7
|
+
def initialize_project
|
12
8
|
Dir.mktmpdir { |dir|
|
13
9
|
temporary_folder = dir
|
14
10
|
temporary_soar_sc_folder = "#{temporary_folder}/soar_sc"
|
15
|
-
`git --git-dir=/dev/null clone --quiet --progress --branch #{
|
11
|
+
`git --git-dir=/dev/null clone --quiet --progress --branch #{@options[:soar_sc_refspec]} --depth=1 git@gitlab.host-h.net:hetznerZA/soar_sc.git #{temporary_soar_sc_folder}`
|
16
12
|
|
17
|
-
`yes | cp -rf #{temporary_soar_sc_folder}/config #{@
|
18
|
-
`yes | cp -rf #{temporary_soar_sc_folder}/docker #{@
|
19
|
-
`yes | cp -rf #{temporary_soar_sc_folder}/lib #{@
|
20
|
-
`yes | cp -rf #{temporary_soar_sc_folder}/smaak #{@
|
21
|
-
`yes | cp -rf #{temporary_soar_sc_folder}/config.ru #{@
|
22
|
-
`yes | cp -rf #{temporary_soar_sc_folder}/Gemfile #{@
|
23
|
-
`yes | cp -rf #{temporary_soar_sc_folder}/.ruby-gemset #{@
|
24
|
-
`yes | cp -rf #{temporary_soar_sc_folder}/.ruby-version #{@
|
25
|
-
`yes | cp -rf #{temporary_soar_sc_folder}/.gitignore #{@
|
13
|
+
`yes | cp -rf #{temporary_soar_sc_folder}/config #{@options[:project_root]}`
|
14
|
+
`yes | cp -rf #{temporary_soar_sc_folder}/docker #{@options[:project_root]}`
|
15
|
+
`yes | cp -rf #{temporary_soar_sc_folder}/lib #{@options[:project_root]}`
|
16
|
+
`yes | cp -rf #{temporary_soar_sc_folder}/smaak #{@options[:project_root]}`
|
17
|
+
`yes | cp -rf #{temporary_soar_sc_folder}/config.ru #{@options[:project_root]}`
|
18
|
+
`yes | cp -rf #{temporary_soar_sc_folder}/Gemfile #{@options[:project_root]}`
|
19
|
+
`yes | cp -rf #{temporary_soar_sc_folder}/.ruby-gemset #{@options[:project_root]}`
|
20
|
+
`yes | cp -rf #{temporary_soar_sc_folder}/.ruby-version #{@options[:project_root]}`
|
21
|
+
`yes | cp -rf #{temporary_soar_sc_folder}/.gitignore #{@options[:project_root]}`
|
26
22
|
}
|
27
23
|
end
|
28
24
|
end
|
data/lib/soaring/packager.rb
CHANGED
@@ -1,15 +1,17 @@
|
|
1
|
+
require 'byebug'
|
2
|
+
|
1
3
|
module Soaring
|
2
4
|
class Packager
|
3
5
|
def initialize(options)
|
4
6
|
@options = options
|
5
7
|
end
|
6
8
|
|
7
|
-
def package
|
9
|
+
def package
|
8
10
|
validate_project if not @options[:ignore_git_checks]
|
9
|
-
build_output_location = generate_build_output_location(
|
11
|
+
build_output_location = generate_build_output_location(@options[:project_root])
|
10
12
|
update_project_commit_hash
|
11
|
-
`mkdir -p #{
|
12
|
-
`zip -r #{build_output_location} * .ebextensions --exclude=build/* --exclude=config/environment.yml`
|
13
|
+
`mkdir -p #{@options[:project_root]}/build`
|
14
|
+
`cd #{@options[:project_root]}; zip -r #{build_output_location} * .ebextensions --exclude=build/* --exclude=config/environment.yml`
|
13
15
|
puts "Build packaged at #{build_output_location}"
|
14
16
|
end
|
15
17
|
|
@@ -25,19 +27,31 @@ module Soaring
|
|
25
27
|
|
26
28
|
def generate_build_output_location(project_folder)
|
27
29
|
service_name = File.split(project_folder)[-1]
|
28
|
-
revision_hash = `git rev-parse --short HEAD`.chomp
|
29
30
|
timestamp = Time.now.strftime("%F-%H%M%S")
|
30
|
-
"#{project_folder}/build/build_#{service_name}_#{
|
31
|
+
"#{project_folder}/build/build_#{service_name}_#{get_short_commit_hash}_#{timestamp}.zip"
|
31
32
|
end
|
32
33
|
|
33
34
|
def update_project_commit_hash
|
34
|
-
|
35
|
+
response, exit_status = Executor::execute("cd #{@options[:project_root]}; git rev-parse HEAD > commit-hash")
|
36
|
+
if not exit_status.success?
|
37
|
+
puts 'Failed to package, unable to get commit hash from local git repository'
|
38
|
+
exit 1
|
39
|
+
end
|
35
40
|
end
|
36
41
|
|
37
42
|
def is_git_repo_up_to_date?
|
38
|
-
|
39
|
-
return true if '' ==
|
43
|
+
response, exit_status = Executor::execute("cd #{@options[:project_root]}; git status --porcelain")
|
44
|
+
return true if ('' == response) and (exit_status.success?)
|
40
45
|
false
|
41
46
|
end
|
47
|
+
|
48
|
+
def get_short_commit_hash
|
49
|
+
response, exit_status = Executor::execute("cd #{@options[:project_root]}; git rev-parse --short HEAD")
|
50
|
+
if not exit_status.success?
|
51
|
+
puts 'Failed to package, unable to get short commit hash from local git repository'
|
52
|
+
exit 1
|
53
|
+
end
|
54
|
+
response.chomp
|
55
|
+
end
|
42
56
|
end
|
43
57
|
end
|
data/lib/soaring/runner.rb
CHANGED
@@ -4,16 +4,11 @@ module Soaring
|
|
4
4
|
@options = options
|
5
5
|
end
|
6
6
|
|
7
|
-
def run
|
8
|
-
environment = 'development'
|
9
|
-
environment = @options[:environment] if @options[:environment]
|
10
|
-
port = 9393
|
11
|
-
port = @options[:port] if @options[:port]
|
12
|
-
|
7
|
+
def run
|
13
8
|
bind_address = '0.0.0.0'
|
14
|
-
rackup_parameters = "-E #{environment} ./config.ru -p #{port} --host #{bind_address}"
|
9
|
+
rackup_parameters = "-E #{@options[:environment]} ./config.ru -p #{@options[:port]} --host #{bind_address}"
|
15
10
|
puts "starting rackup with parameters #{rackup_parameters}" if @options[:verbose]
|
16
|
-
|
11
|
+
exec("bundle exec rackup #{rackup_parameters}")
|
17
12
|
end
|
18
13
|
|
19
14
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'open3'
|
2
|
+
|
3
|
+
module Soaring
|
4
|
+
class Executor
|
5
|
+
def self.execute(command)
|
6
|
+
captured_stdout = ''
|
7
|
+
captured_stderr = ''
|
8
|
+
exit_status = Open3.popen3(ENV, command) {|stdin, stdout, stderr, wait_thr|
|
9
|
+
pid = wait_thr.pid # pid of the started process.
|
10
|
+
stdin.close
|
11
|
+
captured_stdout = stdout.read
|
12
|
+
captured_stderr = stderr.read
|
13
|
+
wait_thr.value # Process::Status object returned.
|
14
|
+
}
|
15
|
+
["#{captured_stdout}#{captured_stderr}", exit_status]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/soaring/version.rb
CHANGED
data/lib/soaring.rb
CHANGED
data/soaring.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soaring
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Barney de Villiers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '9'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: thor
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.19'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.19'
|
69
83
|
description: A collection of command line tools that simplifies the creation, development
|
70
84
|
and packaging of a soar project for deployment at Hetzner
|
71
85
|
email:
|
@@ -77,6 +91,7 @@ extra_rdoc_files: []
|
|
77
91
|
files:
|
78
92
|
- ".gitignore"
|
79
93
|
- ".rspec"
|
94
|
+
- Gemfile
|
80
95
|
- LICENSE.txt
|
81
96
|
- README.md
|
82
97
|
- bin/soaring
|
@@ -85,6 +100,7 @@ files:
|
|
85
100
|
- lib/soaring/initializer.rb
|
86
101
|
- lib/soaring/packager.rb
|
87
102
|
- lib/soaring/runner.rb
|
103
|
+
- lib/soaring/tools.rb
|
88
104
|
- lib/soaring/version.rb
|
89
105
|
- soaring.gemspec
|
90
106
|
homepage: https://github.com/hetznerZA/soaring
|