smartmachine 0.8.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE.txt +661 -0
- data/README.md +147 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/smartmachine +3 -0
- data/lib/smart_machine/apps/app.rb +165 -181
- data/lib/smart_machine/apps/container.rb +120 -0
- data/lib/smart_machine/apps/manager.rb +182 -0
- data/lib/smart_machine/base.rb +24 -6
- data/lib/smart_machine/buildpackers/buildpacker.rb +95 -0
- data/lib/smart_machine/{engine/buildpacks → buildpackers}/rails/Dockerfile +3 -3
- data/lib/smart_machine/buildpackers/rails.rb +221 -0
- data/lib/smart_machine/commands/app.rb +112 -0
- data/lib/smart_machine/commands/buildpacker.rb +53 -0
- data/lib/smart_machine/commands/credentials.rb +17 -0
- data/lib/smart_machine/commands/docker.rb +23 -0
- data/lib/smart_machine/commands/engine.rb +27 -0
- data/lib/smart_machine/commands/grid.rb +33 -0
- data/lib/smart_machine/commands/grid_commands/elasticsearch.rb +68 -0
- data/lib/smart_machine/commands/grid_commands/minio.rb +65 -0
- data/lib/smart_machine/commands/grid_commands/mysql.rb +71 -0
- data/lib/smart_machine/commands/grid_commands/nginx.rb +53 -0
- data/lib/smart_machine/commands/grid_commands/prereceiver.rb +96 -0
- data/lib/smart_machine/commands/grid_commands/redis.rb +65 -0
- data/lib/smart_machine/commands/grid_commands/scheduler.rb +15 -0
- data/lib/smart_machine/commands/grid_commands/sub_thor.rb +15 -0
- data/lib/smart_machine/commands/machine.rb +24 -0
- data/lib/smart_machine/commands/syncer.rb +23 -0
- data/lib/smart_machine/commands/utilities.rb +37 -0
- data/lib/smart_machine/commands.rb +66 -0
- data/lib/smart_machine/configuration.rb +79 -0
- data/lib/smart_machine/credentials.rb +93 -95
- data/lib/smart_machine/docker.rb +144 -143
- data/lib/smart_machine/engine/Dockerfile +7 -5
- data/lib/smart_machine/engine.rb +104 -79
- data/lib/smart_machine/grids/elasticsearch.rb +70 -89
- data/lib/smart_machine/grids/minio.rb +79 -68
- data/lib/smart_machine/grids/mysql.rb +207 -202
- data/lib/smart_machine/grids/nginx.rb +176 -135
- data/lib/smart_machine/grids/prereceiver/Dockerfile +2 -2
- data/lib/smart_machine/grids/prereceiver/pre-receive +17 -0
- data/lib/smart_machine/grids/prereceiver.rb +169 -169
- data/lib/smart_machine/grids/redis.rb +75 -57
- data/lib/smart_machine/grids/scheduler/Dockerfile +1 -1
- data/lib/smart_machine/logger.rb +26 -26
- data/lib/smart_machine/machine.rb +128 -194
- data/lib/smart_machine/scp.rb +15 -0
- data/lib/smart_machine/ssh.rb +69 -40
- data/lib/smart_machine/syncer.rb +133 -0
- data/lib/smart_machine/templates/dotsmartmachine/Gemfile +7 -0
- data/lib/smart_machine/templates/dotsmartmachine/config/elasticsearch.yml +5 -0
- data/lib/smart_machine/templates/dotsmartmachine/config/environment.rb +0 -9
- data/lib/smart_machine/templates/dotsmartmachine/config/minio.yml +13 -0
- data/lib/smart_machine/templates/dotsmartmachine/config/mysql/schedule.rb +3 -3
- data/lib/smart_machine/templates/dotsmartmachine/config/mysql.yml +13 -0
- data/lib/smart_machine/templates/dotsmartmachine/config/prereceiver.yml +7 -0
- data/lib/smart_machine/templates/dotsmartmachine/config/redis.yml +15 -0
- data/lib/smart_machine/templates/dotsmartmachine/config/users.yml +1 -1
- data/lib/smart_machine/templates/dotsmartmachine/gitignore-template +47 -0
- data/lib/smart_machine/templates/dotsmartmachine/{grids/elasticsearch/data → vendor}/.keep +0 -0
- data/lib/smart_machine/version.rb +30 -6
- data/lib/smart_machine.rb +42 -16
- metadata +97 -47
- data/CHANGELOG.rdoc +0 -0
- data/MIT-LICENSE +0 -21
- data/README.rdoc +0 -87
- data/bin/buildpacker +0 -8
- data/bin/prereceiver +0 -8
- data/bin/scheduler +0 -18
- data/bin/smartmachine +0 -81
- data/bin/smartrunner +0 -33
- data/lib/smart_machine/apps/rails.rb +0 -250
- data/lib/smart_machine/apps.rb +0 -14
- data/lib/smart_machine/boot.rb +0 -32
- data/lib/smart_machine/buildpacker.rb +0 -106
- data/lib/smart_machine/gem_version.rb +0 -17
- data/lib/smart_machine/grids.rb +0 -18
- data/lib/smart_machine/sync.rb +0 -120
- data/lib/smart_machine/templates/dotsmartmachine/grids/elasticsearch/logs/.keep +0 -0
- data/lib/smart_machine/templates/dotsmartmachine/grids/minio/data/.keep +0 -0
- data/lib/smart_machine/templates/dotsmartmachine/grids/mysql/backups/.keep +0 -0
- data/lib/smart_machine/templates/dotsmartmachine/grids/mysql/data/.keep +0 -0
- data/lib/smart_machine/templates/dotsmartmachine/grids/prereceiver/pre-receive +0 -17
- data/lib/smart_machine/templates/dotsmartmachine/grids/redis/data/.keep +0 -0
- data/lib/smart_machine/user.rb +0 -38
@@ -0,0 +1,53 @@
|
|
1
|
+
module SmartMachine
|
2
|
+
module Commands
|
3
|
+
class Buildpacker < Thor
|
4
|
+
include Utilities
|
5
|
+
|
6
|
+
desc "install [PACKNAME]", "Install buildpacker"
|
7
|
+
def install(packname)
|
8
|
+
inside_machine_dir do
|
9
|
+
with_docker_running do
|
10
|
+
puts "-----> Installing Buildpacker"
|
11
|
+
machine = SmartMachine::Machine.new
|
12
|
+
machine.run_on_machine commands: "smartengine buildpacker installer #{packname}"
|
13
|
+
puts "-----> Buildpacker Installation Complete"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "uninstall [PACKNAME]", "Uninstall buildpacker"
|
19
|
+
def uninstall(packname)
|
20
|
+
inside_machine_dir do
|
21
|
+
with_docker_running do
|
22
|
+
puts "-----> Uninstalling Buildpacker"
|
23
|
+
machine = SmartMachine::Machine.new
|
24
|
+
machine.run_on_machine commands: "smartengine buildpacker uninstaller #{packname}"
|
25
|
+
puts "-----> Buildpacker Uninstallation Complete"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
desc "installer [PACKNAME]", "Buildpacker installer", hide: true
|
31
|
+
def installer(packname)
|
32
|
+
inside_engine_machine_dir do
|
33
|
+
buildpacker = SmartMachine::Buildpackers::Buildpacker.new(packname: packname)
|
34
|
+
buildpacker.installer
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
desc "uninstaller [PACKNAME]", "Buildpacker uninstaller", hide: true
|
39
|
+
def uninstaller(packname)
|
40
|
+
inside_engine_machine_dir do
|
41
|
+
buildpacker = SmartMachine::Buildpackers::Buildpacker.new(packname: packname)
|
42
|
+
buildpacker.uninstaller
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
desc "packer", "Pack a buildpack. System command. Should not be used by user.", hide: true
|
47
|
+
def packer(packname)
|
48
|
+
buildpacker = SmartMachine::Buildpackers::Buildpacker.new(packname: packname)
|
49
|
+
buildpacker.packer
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module SmartMachine
|
2
|
+
module Commands
|
3
|
+
class Credentials < Thor
|
4
|
+
include Utilities
|
5
|
+
|
6
|
+
default_task :edit
|
7
|
+
|
8
|
+
desc "edit", "Allows editing the credentials"
|
9
|
+
def edit
|
10
|
+
inside_machine_dir do
|
11
|
+
credentials = SmartMachine::Credentials.new
|
12
|
+
credentials.edit
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module SmartMachine
|
2
|
+
module Commands
|
3
|
+
class Docker < Thor
|
4
|
+
include Utilities
|
5
|
+
|
6
|
+
desc "install", "Install docker"
|
7
|
+
def install
|
8
|
+
inside_machine_dir do
|
9
|
+
docker = SmartMachine::Docker.new
|
10
|
+
docker.install
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "uninstall", "Uninstall docker"
|
15
|
+
def uninstall
|
16
|
+
inside_machine_dir do
|
17
|
+
docker = SmartMachine::Docker.new
|
18
|
+
docker.uninstall
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module SmartMachine
|
2
|
+
module Commands
|
3
|
+
class Engine < Thor
|
4
|
+
include Utilities
|
5
|
+
|
6
|
+
desc "install", "Install engine"
|
7
|
+
def install
|
8
|
+
inside_machine_dir do
|
9
|
+
with_docker_running do
|
10
|
+
engine = SmartMachine::Engine.new
|
11
|
+
engine.install
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
desc "uninstall", "Uninstall engine"
|
17
|
+
def uninstall
|
18
|
+
inside_machine_dir do
|
19
|
+
with_docker_running do
|
20
|
+
engine = SmartMachine::Engine.new
|
21
|
+
engine.uninstall
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'smart_machine/commands/grid_commands/sub_thor'
|
2
|
+
require 'smart_machine/commands/grid_commands/elasticsearch'
|
3
|
+
require 'smart_machine/commands/grid_commands/minio'
|
4
|
+
require 'smart_machine/commands/grid_commands/mysql'
|
5
|
+
require 'smart_machine/commands/grid_commands/nginx'
|
6
|
+
require 'smart_machine/commands/grid_commands/prereceiver'
|
7
|
+
require 'smart_machine/commands/grid_commands/redis'
|
8
|
+
|
9
|
+
module SmartMachine
|
10
|
+
module Commands
|
11
|
+
class Grid < Thor
|
12
|
+
include Utilities
|
13
|
+
|
14
|
+
desc "elasticsearch", "Run elasticsearch grid commands"
|
15
|
+
subcommand "elasticsearch", GridCommands::Elasticsearch
|
16
|
+
|
17
|
+
desc "minio", "Run minio grid commands"
|
18
|
+
subcommand "minio", GridCommands::Minio
|
19
|
+
|
20
|
+
desc "mysql", "Run mysql grid commands"
|
21
|
+
subcommand "mysql", GridCommands::Mysql
|
22
|
+
|
23
|
+
desc "nginx", "Run nginx grid commands"
|
24
|
+
subcommand "nginx", GridCommands::Nginx
|
25
|
+
|
26
|
+
desc "prereceiver", "Run prereceiver grid commands"
|
27
|
+
subcommand "prereceiver", GridCommands::Prereceiver
|
28
|
+
|
29
|
+
desc "redis", "Run redis grid commands"
|
30
|
+
subcommand "redis", GridCommands::Redis
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module SmartMachine
|
2
|
+
module Commands
|
3
|
+
module GridCommands
|
4
|
+
class Elasticsearch < SubThor
|
5
|
+
include Utilities
|
6
|
+
|
7
|
+
desc "up", "Take UP the elasticsearch grid"
|
8
|
+
option :name, type: :string
|
9
|
+
def up
|
10
|
+
inside_machine_dir do
|
11
|
+
with_docker_running do
|
12
|
+
machine = SmartMachine::Machine.new
|
13
|
+
name_option = options[:name] ? " --name=#{options[:name]}" : ""
|
14
|
+
machine.run_on_machine commands: "echo 'vm.max_map_count=262144' | sudo tee /etc/sysctl.d/60-smartmachine-elasticsearch.conf && sudo sysctl --system"
|
15
|
+
machine.run_on_machine commands: "smartengine grid elasticsearch uper#{name_option}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
desc "down", "Take DOWN the elasticsearch grid"
|
21
|
+
option :name, type: :string
|
22
|
+
def down
|
23
|
+
inside_machine_dir do
|
24
|
+
with_docker_running do
|
25
|
+
machine = SmartMachine::Machine.new
|
26
|
+
name_option = options[:name] ? " --name=#{options[:name]}" : ""
|
27
|
+
machine.run_on_machine commands: "smartengine grid elasticsearch downer#{name_option}"
|
28
|
+
# NOTE: sysctl does not reset this setting until restart of system even after sudo sysctl --system is run.
|
29
|
+
machine.run_on_machine commands: "test $(docker ps -aq --filter label=smartmachine.elasticsearch.name | wc -l) -eq 0 && test -f /etc/sysctl.d/60-smartmachine-elasticsearch.conf && sudo rm /etc/sysctl.d/60-smartmachine-elasticsearch.conf && sudo sysctl --system"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "uper", "Elasticsearch grid uper", hide: true
|
35
|
+
option :name, type: :string
|
36
|
+
def uper
|
37
|
+
inside_engine_machine_dir do
|
38
|
+
if options[:name]
|
39
|
+
elasticsearch = SmartMachine::Grids::Elasticsearch.new(name: options[:name])
|
40
|
+
elasticsearch.uper
|
41
|
+
else
|
42
|
+
SmartMachine.config.grids.elasticsearch.each do |name, config|
|
43
|
+
elasticsearch = SmartMachine::Grids::Elasticsearch.new(name: name.to_s)
|
44
|
+
elasticsearch.uper
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
desc "downer", "Elasticsearch grid downer", hide: true
|
51
|
+
option :name, type: :string
|
52
|
+
def downer
|
53
|
+
inside_engine_machine_dir do
|
54
|
+
if options[:name]
|
55
|
+
elasticsearch = SmartMachine::Grids::Elasticsearch.new(name: options[:name])
|
56
|
+
elasticsearch.downer
|
57
|
+
else
|
58
|
+
SmartMachine.config.grids.elasticsearch.each do |name, config|
|
59
|
+
elasticsearch = SmartMachine::Grids::Elasticsearch.new(name: name.to_s)
|
60
|
+
elasticsearch.downer
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module SmartMachine
|
2
|
+
module Commands
|
3
|
+
module GridCommands
|
4
|
+
class Minio < SubThor
|
5
|
+
include Utilities
|
6
|
+
|
7
|
+
desc "up", "Take UP the minio grid"
|
8
|
+
option :name, type: :string
|
9
|
+
def up
|
10
|
+
inside_machine_dir do
|
11
|
+
with_docker_running do
|
12
|
+
machine = SmartMachine::Machine.new
|
13
|
+
name_option = options[:name] ? " --name=#{options[:name]}" : ""
|
14
|
+
machine.run_on_machine commands: "smartengine grid minio uper#{name_option}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "down", "Take DOWN the minio grid"
|
20
|
+
option :name, type: :string
|
21
|
+
def down
|
22
|
+
inside_machine_dir do
|
23
|
+
with_docker_running do
|
24
|
+
machine = SmartMachine::Machine.new
|
25
|
+
name_option = options[:name] ? " --name=#{options[:name]}" : ""
|
26
|
+
machine.run_on_machine commands: "smartengine grid minio downer#{name_option}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
desc "uper", "Minio grid uper", hide: true
|
32
|
+
option :name, type: :string
|
33
|
+
def uper
|
34
|
+
inside_engine_machine_dir do
|
35
|
+
if options[:name]
|
36
|
+
minio = SmartMachine::Grids::Minio.new(name: options[:name])
|
37
|
+
minio.uper
|
38
|
+
else
|
39
|
+
SmartMachine.config.grids.minio.each do |name, config|
|
40
|
+
minio = SmartMachine::Grids::Minio.new(name: name.to_s)
|
41
|
+
minio.uper
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
desc "downer", "Minio grid downer", hide: true
|
48
|
+
option :name, type: :string
|
49
|
+
def downer
|
50
|
+
inside_engine_machine_dir do
|
51
|
+
if options[:name]
|
52
|
+
minio = SmartMachine::Grids::Minio.new(name: options[:name])
|
53
|
+
minio.downer
|
54
|
+
else
|
55
|
+
SmartMachine.config.grids.minio.each do |name, config|
|
56
|
+
minio = SmartMachine::Grids::Minio.new(name: name.to_s)
|
57
|
+
minio.downer
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module SmartMachine
|
2
|
+
module Commands
|
3
|
+
module GridCommands
|
4
|
+
class Mysql < SubThor
|
5
|
+
include Utilities
|
6
|
+
|
7
|
+
desc "up", "Take UP the mysql grid"
|
8
|
+
option :name, type: :string
|
9
|
+
def up
|
10
|
+
inside_machine_dir do
|
11
|
+
with_docker_running do
|
12
|
+
machine = SmartMachine::Machine.new
|
13
|
+
name_option = options[:name] ? " --name=#{options[:name]}" : ""
|
14
|
+
machine.run_on_machine commands: "smartengine grid mysql uper#{name_option}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "down", "Take DOWN the mysql grid"
|
20
|
+
option :name, type: :string
|
21
|
+
def down
|
22
|
+
inside_machine_dir do
|
23
|
+
with_docker_running do
|
24
|
+
machine = SmartMachine::Machine.new
|
25
|
+
name_option = options[:name] ? " --name=#{options[:name]}" : ""
|
26
|
+
machine.run_on_machine commands: "smartengine grid mysql downer#{name_option}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# def flushlogs
|
32
|
+
# end
|
33
|
+
|
34
|
+
# def backup
|
35
|
+
# end
|
36
|
+
|
37
|
+
desc "uper", "Mysql grid uper", hide: true
|
38
|
+
option :name, type: :string
|
39
|
+
def uper
|
40
|
+
inside_engine_machine_dir do
|
41
|
+
if options[:name]
|
42
|
+
mysql = SmartMachine::Grids::Mysql.new(name: options[:name])
|
43
|
+
mysql.uper
|
44
|
+
else
|
45
|
+
SmartMachine.config.grids.mysql.each do |name, config|
|
46
|
+
mysql = SmartMachine::Grids::Mysql.new(name: name.to_s)
|
47
|
+
mysql.uper
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
desc "downer", "Mysql grid downer", hide: true
|
54
|
+
option :name, type: :string
|
55
|
+
def downer
|
56
|
+
inside_engine_machine_dir do
|
57
|
+
if options[:name]
|
58
|
+
mysql = SmartMachine::Grids::Mysql.new(name: options[:name])
|
59
|
+
mysql.downer
|
60
|
+
else
|
61
|
+
SmartMachine.config.grids.mysql.each do |name, config|
|
62
|
+
mysql = SmartMachine::Grids::Mysql.new(name: name.to_s)
|
63
|
+
mysql.downer
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module SmartMachine
|
2
|
+
module Commands
|
3
|
+
module GridCommands
|
4
|
+
class Nginx < SubThor
|
5
|
+
include Utilities
|
6
|
+
|
7
|
+
desc "up", "Take UP the nginx grid"
|
8
|
+
def up
|
9
|
+
inside_machine_dir do
|
10
|
+
with_docker_running do
|
11
|
+
machine = SmartMachine::Machine.new
|
12
|
+
machine.run_on_machine commands: "smartengine grid nginx uper"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "down", "Take DOWN the nginx grid"
|
18
|
+
def down
|
19
|
+
inside_machine_dir do
|
20
|
+
with_docker_running do
|
21
|
+
machine = SmartMachine::Machine.new
|
22
|
+
machine.run_on_machine commands: "smartengine grid nginx downer"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
desc "users:edit", "Allows editing the users"
|
28
|
+
map "users:edit" => :users_edit
|
29
|
+
def users_edit
|
30
|
+
inside_machine_dir do
|
31
|
+
system("#{ENV['EDITOR']} config/users.yml")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "uper", "Nginx grid uper", hide: true
|
36
|
+
def uper
|
37
|
+
inside_engine_machine_dir do
|
38
|
+
nginx = SmartMachine::Grids::Nginx.new
|
39
|
+
nginx.uper
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
desc "downer", "Nginx grid downer", hide: true
|
44
|
+
def downer
|
45
|
+
inside_engine_machine_dir do
|
46
|
+
nginx = SmartMachine::Grids::Nginx.new
|
47
|
+
nginx.downer
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
module SmartMachine
|
2
|
+
module Commands
|
3
|
+
module GridCommands
|
4
|
+
class Prereceiver < SubThor
|
5
|
+
include Utilities
|
6
|
+
|
7
|
+
desc "install", "Install prereceiver grid"
|
8
|
+
def install
|
9
|
+
inside_machine_dir do
|
10
|
+
with_docker_running do
|
11
|
+
puts "-----> Installing Prereceiver"
|
12
|
+
machine = SmartMachine::Machine.new
|
13
|
+
machine.run_on_machine commands: "smartengine grid prereceiver installer"
|
14
|
+
puts "-----> Prereceiver Installation Complete"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "uninstall", "Uninstall prereceiver grid"
|
20
|
+
def uninstall
|
21
|
+
inside_machine_dir do
|
22
|
+
with_docker_running do
|
23
|
+
puts "-----> Installing Prereceiver"
|
24
|
+
machine = SmartMachine::Machine.new
|
25
|
+
machine.run_on_machine commands: "smartengine grid prereceiver uninstaller"
|
26
|
+
puts "-----> Prereceiver Installation Complete"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
desc "up", "Take UP the prereceiver grid"
|
32
|
+
def up
|
33
|
+
inside_machine_dir do
|
34
|
+
with_docker_running do
|
35
|
+
machine = SmartMachine::Machine.new
|
36
|
+
machine.run_on_machine commands: "smartengine grid prereceiver uper"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
desc "down", "Take DOWN the prereceiver grid"
|
42
|
+
def down
|
43
|
+
inside_machine_dir do
|
44
|
+
with_docker_running do
|
45
|
+
machine = SmartMachine::Machine.new
|
46
|
+
machine.run_on_machine commands: "smartengine grid prereceiver downer"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
desc "installer", "Prereceiver grid installer", hide: true
|
52
|
+
def installer
|
53
|
+
inside_engine_machine_dir do
|
54
|
+
name, config = SmartMachine.config.grids.prereceiver.first
|
55
|
+
prereceiver = SmartMachine::Grids::Prereceiver.new(name: name.to_s)
|
56
|
+
prereceiver.installer
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
desc "uninstaller", "Prereceiver grid uninstaller", hide: true
|
61
|
+
def uninstaller
|
62
|
+
inside_engine_machine_dir do
|
63
|
+
name, config = SmartMachine.config.grids.prereceiver.first
|
64
|
+
prereceiver = SmartMachine::Grids::Prereceiver.new(name: name.to_s)
|
65
|
+
prereceiver.uninstaller
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
desc "uper", "Prereceiver grid uper", hide: true
|
70
|
+
def uper
|
71
|
+
inside_engine_machine_dir do
|
72
|
+
name, config = SmartMachine.config.grids.prereceiver.first
|
73
|
+
prereceiver = SmartMachine::Grids::Prereceiver.new(name: name.to_s)
|
74
|
+
prereceiver.uper
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
desc "downer", "Prereceiver grid downer", hide: true
|
79
|
+
def downer
|
80
|
+
inside_engine_machine_dir do
|
81
|
+
name, config = SmartMachine.config.grids.prereceiver.first
|
82
|
+
prereceiver = SmartMachine::Grids::Prereceiver.new(name: name.to_s)
|
83
|
+
prereceiver.downer
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
desc "prereceive", "Prereceiver grid prereceive", hide: true
|
88
|
+
def prereceive(appname, username, oldrev, newrev, refname)
|
89
|
+
name, config = SmartMachine.config.grids.prereceiver.first
|
90
|
+
prereceiver = SmartMachine::Grids::Prereceiver.new(name: name.to_s)
|
91
|
+
prereceiver.prereceive(appname: appname, username: username, oldrev: oldrev, newrev: newrev, refname: refname)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module SmartMachine
|
2
|
+
module Commands
|
3
|
+
module GridCommands
|
4
|
+
class Redis < SubThor
|
5
|
+
include Utilities
|
6
|
+
|
7
|
+
desc "up", "Take UP the redis grid"
|
8
|
+
option :name, type: :string
|
9
|
+
def up
|
10
|
+
inside_machine_dir do
|
11
|
+
with_docker_running do
|
12
|
+
machine = SmartMachine::Machine.new
|
13
|
+
name_option = options[:name] ? " --name=#{options[:name]}" : ""
|
14
|
+
machine.run_on_machine commands: "smartengine grid redis uper#{name_option}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "down", "Take DOWN the redis grid"
|
20
|
+
option :name, type: :string
|
21
|
+
def down
|
22
|
+
inside_machine_dir do
|
23
|
+
with_docker_running do
|
24
|
+
machine = SmartMachine::Machine.new
|
25
|
+
name_option = options[:name] ? " --name=#{options[:name]}" : ""
|
26
|
+
machine.run_on_machine commands: "smartengine grid redis downer#{name_option}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
desc "uper", "Redis grid uper", hide: true
|
32
|
+
option :name, type: :string
|
33
|
+
def uper
|
34
|
+
inside_engine_machine_dir do
|
35
|
+
if options[:name]
|
36
|
+
redis = SmartMachine::Grids::Redis.new(name: options[:name])
|
37
|
+
redis.uper
|
38
|
+
else
|
39
|
+
SmartMachine.config.grids.redis.each do |name, config|
|
40
|
+
redis = SmartMachine::Grids::Redis.new(name: name.to_s)
|
41
|
+
redis.uper
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
desc "downer", "Redis grid downer", hide: true
|
48
|
+
option :name, type: :string
|
49
|
+
def downer
|
50
|
+
inside_engine_machine_dir do
|
51
|
+
if options[:name]
|
52
|
+
redis = SmartMachine::Grids::Redis.new(name: options[:name])
|
53
|
+
redis.downer
|
54
|
+
else
|
55
|
+
SmartMachine.config.grids.redis.each do |name, config|
|
56
|
+
redis = SmartMachine::Grids::Redis.new(name: name.to_s)
|
57
|
+
redis.downer
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module SmartMachine
|
2
|
+
module Commands
|
3
|
+
module GridCommands
|
4
|
+
class SubThor < Thor
|
5
|
+
def self.banner(command, namespace = nil, subcommand = false)
|
6
|
+
"#{basename} grid #{subcommand_prefix} #{command.usage}"
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.subcommand_prefix
|
10
|
+
self.name.gsub(%r{.*::}, '').gsub(%r{^[A-Z]}) { |match| match[0].downcase }.gsub(%r{[A-Z]}) { |match| "-#{match[0].downcase}" }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module SmartMachine
|
2
|
+
module Commands
|
3
|
+
class Machine < Thor
|
4
|
+
include Utilities
|
5
|
+
|
6
|
+
desc "ssh", "SSH into the machine"
|
7
|
+
def ssh
|
8
|
+
inside_machine_dir do
|
9
|
+
ssh = SmartMachine::SSH.new
|
10
|
+
ssh.login
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "run [COMMAND]", "Run commands on the machine"
|
15
|
+
map ["run"] => :runner
|
16
|
+
def runner(*args)
|
17
|
+
inside_machine_dir do
|
18
|
+
machine = SmartMachine::Machine.new
|
19
|
+
machine.run_on_machine(commands: "#{args.join(' ')}")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module SmartMachine
|
2
|
+
module Commands
|
3
|
+
class Syncer < Thor
|
4
|
+
include Utilities
|
5
|
+
|
6
|
+
desc "sync", "Sync files"
|
7
|
+
def sync
|
8
|
+
inside_machine_dir do
|
9
|
+
syncer = SmartMachine::Syncer.new
|
10
|
+
syncer.sync
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "rsync", "Run rsync command. System command. Should not be used by user.", hide: true
|
15
|
+
def rsync(*args)
|
16
|
+
inside_engine_machine_dir do
|
17
|
+
syncer = SmartMachine::Syncer.new
|
18
|
+
syncer.rsync(args)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|