smartmachine 0.8.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -1,170 +1,170 @@
|
|
1
|
-
# The main SmartMachine Grids Git driver
|
2
1
|
module SmartMachine
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
end
|
2
|
+
class Grids
|
3
|
+
class Prereceiver < SmartMachine::Base
|
4
|
+
|
5
|
+
def initialize(name:)
|
6
|
+
config = SmartMachine.config.grids.prereceiver.dig(name.to_sym)
|
7
|
+
raise "prereceiver config for #{name} not found." unless config
|
8
|
+
|
9
|
+
@git_domain = config.dig(:git_domain)
|
10
|
+
@letsencrypt_test = config.dig(:letsencrypt_test)
|
11
|
+
@letsencrypt_email = SmartMachine.config.sysadmin_email
|
12
|
+
@image_name = "smartmachine/prereceiver:#{SmartMachine.version}"
|
13
|
+
|
14
|
+
@name = name.to_s
|
15
|
+
@home_dir = File.expand_path('~')
|
16
|
+
end
|
17
|
+
|
18
|
+
def installer
|
19
|
+
unless system("docker image inspect #{@image_name}", [:out, :err] => File::NULL)
|
20
|
+
puts "-----> Creating image #{@image_name} ... "
|
21
|
+
command = [
|
22
|
+
"docker image build -t #{@image_name}",
|
23
|
+
"--build-arg SMARTMACHINE_VERSION=#{SmartMachine.version}",
|
24
|
+
"#{SmartMachine.config.gem_dir}/lib/smart_machine/grids/prereceiver"
|
25
|
+
]
|
26
|
+
if system(command.join(" "), out: File::NULL)
|
27
|
+
puts "done"
|
28
|
+
else
|
29
|
+
raise "Error: Could not install Prereceiver."
|
30
|
+
end
|
31
|
+
else
|
32
|
+
raise "Error: Prereceiver already installed. Please uninstall using 'smartmachine grids prereceiver uninstall' and try installing again."
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def uninstaller
|
37
|
+
unless system("docker inspect -f '{{.State.Running}}' '#{@name}'", [:out, :err] => File::NULL)
|
38
|
+
if system("docker image inspect #{@image_name}", [:out, :err] => File::NULL)
|
39
|
+
puts "-----> Removing image #{@image_name} ... "
|
40
|
+
if system("docker image rm #{@image_name}", out: File::NULL)
|
41
|
+
puts "done"
|
42
|
+
end
|
43
|
+
else
|
44
|
+
raise "Error: Prereceiver already uninstalled. Please install using 'smartmachine grids prereceiver install' and try uninstalling again."
|
45
|
+
end
|
46
|
+
else
|
47
|
+
raise "Error: Prereceiver is currently running. Please stop the prereceiver using 'smartmachine grids prereceiver down' and try uninstalling again."
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def uper
|
52
|
+
if system("docker image inspect #{@image_name}", [:out, :err] => File::NULL)
|
53
|
+
FileUtils.mkdir_p("#{@home_dir}/machine/grids/prereceiver/#{@name}")
|
54
|
+
system("cp #{SmartMachine.config.gem_dir}/lib/smart_machine/grids/prereceiver/pre-receive #{@home_dir}/machine/grids/prereceiver/#{@name}/pre-receive")
|
55
|
+
system("chmod +x #{@home_dir}/machine/grids/prereceiver/#{@name}/pre-receive")
|
56
|
+
|
57
|
+
puts "-----> Creating container #{@name} with image #{@image_name} ... "
|
58
|
+
command = [
|
59
|
+
"docker create",
|
60
|
+
"--name='#{@name}'",
|
61
|
+
"--env VIRTUAL_PROTO=fastcgi",
|
62
|
+
"--env VIRTUAL_HOST=#{@git_domain}",
|
63
|
+
"--env LETSENCRYPT_HOST=#{@git_domain}",
|
64
|
+
"--env LETSENCRYPT_EMAIL=#{@letsencrypt_email}",
|
65
|
+
"--env LETSENCRYPT_TEST=#{@letsencrypt_test}",
|
66
|
+
"--env GIT_PROJECT_ROOT=#{@home_dir}/machine/apps/repositories",
|
67
|
+
"--env GIT_HTTP_EXPORT_ALL=''",
|
68
|
+
"--user `id -u`",
|
69
|
+
"--workdir #{@home_dir}/machine",
|
70
|
+
"--expose='9000'",
|
71
|
+
"--volume='#{@home_dir}/smartmachine/config:#{@home_dir}/machine/config'",
|
72
|
+
"--volume='#{@home_dir}/smartmachine/apps:#{@home_dir}/machine/apps'",
|
73
|
+
"--volume='#{@home_dir}/smartmachine/grids/prereceiver/#{@name}:#{@home_dir}/machine/grids/prereceiver/#{@name}'",
|
74
|
+
"--volume='/var/run/docker.sock:/var/run/docker.sock:ro'",
|
75
|
+
"--restart='always'",
|
76
|
+
"--network='nginx-network'",
|
77
|
+
"#{@image_name}"
|
78
|
+
]
|
79
|
+
if system(command.join(" "), out: File::NULL)
|
80
|
+
puts "done"
|
81
|
+
|
82
|
+
puts "-----> Starting container #{@name} with image #{@image_name} ... "
|
83
|
+
if system("docker start #{@name}", out: File::NULL)
|
84
|
+
puts "done"
|
85
|
+
else
|
86
|
+
raise "Error: Could not start the created image to take UP the prereceiver."
|
87
|
+
end
|
88
|
+
else
|
89
|
+
raise "Error: Could not create image to take UP the prereceiver."
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# Stopping & Removing containers - in reverse order
|
95
|
+
def downer
|
96
|
+
if system("docker inspect -f '{{.State.Running}}' '#{@name}'", [:out, :err] => File::NULL)
|
97
|
+
puts "-----> Stopping container #{@name} with image #{@image_name} ... "
|
98
|
+
if system("docker stop '#{@name}'", out: File::NULL)
|
99
|
+
puts "done"
|
100
|
+
|
101
|
+
puts "-----> Removing container #{@name} with image #{@image_name} ... "
|
102
|
+
if system("docker rm '#{@name}'", out: File::NULL)
|
103
|
+
|
104
|
+
system("rm -r #{@home_dir}/machine/grids/prereceiver/#{@name}")
|
105
|
+
|
106
|
+
puts "done"
|
107
|
+
end
|
108
|
+
end
|
109
|
+
else
|
110
|
+
puts "-----> Container '#{@name}' is currently not running."
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def prereceive(appname:, username:, oldrev:, newrev:, refname:)
|
115
|
+
manager = SmartMachine::Apps::Manager.new(appname: appname)
|
116
|
+
|
117
|
+
# Loading SmartMachine Environment File
|
118
|
+
if File.exist?("#{@home_dir}/machine/config/environment.rb")
|
119
|
+
require "#{@home_dir}/machine/config/environment"
|
120
|
+
end
|
121
|
+
|
122
|
+
logger.formatter = proc do |severity, datetime, progname, message|
|
123
|
+
severity_text = { "DEBUG" => "\u{1f527} #{severity}:", "INFO" => " \u{276f}", "WARN" => "\u{2757} #{severity}:",
|
124
|
+
"ERROR" => "\u{274c} #{severity}:", "FATAL" => "\u{2b55} #{severity}:", "UNKNOWN" => "\u{2753} #{severity}:"
|
125
|
+
}
|
126
|
+
"\t\t\t\t#{severity_text[severity]} #{message}\n"
|
127
|
+
end
|
128
|
+
|
129
|
+
# Load vars and environment
|
130
|
+
container_path = "#{@home_dir}/machine/apps/containers/#{appname}"
|
131
|
+
|
132
|
+
# Verify the user and ensure the user is correct and has access to this repository
|
133
|
+
unless manager.env_vars.present? && manager.env_vars['USERNAME'] == username
|
134
|
+
logger.error "Unauthorized."
|
135
|
+
return
|
136
|
+
end
|
137
|
+
|
138
|
+
# Only run this script for the main branch. You can remove this
|
139
|
+
# if block if you wish to run it for others as well.
|
140
|
+
if refname == "refs/heads/main"
|
141
|
+
logger.info "Loading Application ..."
|
142
|
+
|
143
|
+
# Note: There should be no space between + and " in version.
|
144
|
+
# Note: date will be UTC date until timezone has been changed.
|
145
|
+
version = `date +"%Y%m%d%H%M%S"`.chomp!
|
146
|
+
container_path_with_version = "#{container_path}/releases/#{version}"
|
147
|
+
|
148
|
+
unless Dir.exist? container_path_with_version
|
149
|
+
FileUtils.mkdir_p(container_path_with_version)
|
150
|
+
if system("git archive #{newrev} | tar -x -C #{container_path_with_version}")
|
151
|
+
# Deploy app with the latest release
|
152
|
+
manager.deploy
|
153
|
+
else
|
154
|
+
logger.fatal "Could not extract new app version ... Failed."
|
155
|
+
return
|
156
|
+
end
|
157
|
+
else
|
158
|
+
logger.fatal "This version name already exists ... Failed."
|
159
|
+
return
|
160
|
+
end
|
161
|
+
else
|
162
|
+
# Allow the push to complete for all other branches normally.
|
163
|
+
exit 10
|
164
|
+
end
|
165
|
+
|
166
|
+
logger.formatter = nil
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
@@ -1,58 +1,76 @@
|
|
1
|
-
# The main SmartMachine Grids Redis driver
|
2
1
|
module SmartMachine
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
2
|
+
class Grids
|
3
|
+
class Redis < SmartMachine::Base
|
4
|
+
def initialize(name:)
|
5
|
+
config = SmartMachine.config.grids.redis.dig(name.to_sym)
|
6
|
+
raise "redis config for #{name} not found." unless config
|
7
|
+
|
8
|
+
@port = config.dig(:port)
|
9
|
+
@password = config.dig(:password)
|
10
|
+
@appendonly = config.dig(:appendonly)
|
11
|
+
@maxmemory = config.dig(:maxmemory)
|
12
|
+
@maxmemory_policy = config.dig(:maxmemory_policy)
|
13
|
+
@modules = config.dig(:modules)&.map { |module_name| "--loadmodule /usr/lib/redis/modules/#{module_name}.so" } || []
|
14
|
+
@modules.push("Plugin /var/opt/redislabs/modules/rg/plugin/gears_python.so")
|
15
|
+
|
16
|
+
@name = name.to_s
|
17
|
+
@home_dir = File.expand_path('~')
|
18
|
+
end
|
19
|
+
|
20
|
+
def uper
|
21
|
+
# Creating networks
|
22
|
+
unless system("docker network inspect #{@name}-network", [:out, :err] => File::NULL)
|
23
|
+
puts "-----> Creating network #{@name}-network ... "
|
24
|
+
if system("docker network create #{@name}-network", out: File::NULL)
|
25
|
+
puts "done"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
FileUtils.mkdir_p("#{@home_dir}/machine/grids/redis/#{@name}/data")
|
30
|
+
|
31
|
+
# Creating & Starting containers
|
32
|
+
puts "-----> Creating container #{@name} ... "
|
33
|
+
|
34
|
+
command = [
|
35
|
+
"docker create",
|
36
|
+
"--name='#{@name}'",
|
37
|
+
"--user `id -u`:`id -g`",
|
38
|
+
"--publish='#{@port}:#{@port}'",
|
39
|
+
"--volume='#{@home_dir}/smartmachine/grids/redis/#{@name}/data:/data'",
|
40
|
+
"--restart='always'",
|
41
|
+
"--network='#{@name}-network'",
|
42
|
+
"redislabs/redismod:latest --port #{@port} --requirepass #{@password} --appendonly #{@appendonly} --maxmemory #{@maxmemory} --maxmemory-policy #{@maxmemory_policy} #{@modules.join(' ')}"
|
43
|
+
]
|
44
|
+
if system(command.compact.join(" "), out: File::NULL)
|
45
|
+
puts "done"
|
46
|
+
puts "-----> Starting container #{@name} ... "
|
47
|
+
if system("docker start #{@name}", out: File::NULL)
|
48
|
+
puts "done"
|
49
|
+
else
|
50
|
+
raise "Error: Could not start the created #{@name} container"
|
51
|
+
end
|
52
|
+
else
|
53
|
+
raise "Error: Could not create #{@name} container"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# Stopping & Removing containers - in reverse order
|
58
|
+
def downer
|
59
|
+
puts "-----> Stopping container #{@name} ... "
|
60
|
+
if system("docker stop '#{@name}'", out: File::NULL)
|
61
|
+
puts "done"
|
62
|
+
puts "-----> Removing container #{@name} ... "
|
63
|
+
if system("docker rm '#{@name}'", out: File::NULL)
|
64
|
+
puts "done"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# Removing networks
|
69
|
+
puts "-----> Removing network #{@name}-network ... "
|
70
|
+
if system("docker network rm #{@name}-network", out: File::NULL)
|
71
|
+
puts "done"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
data/lib/smart_machine/logger.rb
CHANGED
@@ -3,33 +3,33 @@ require "logger"
|
|
3
3
|
$stdout.sync = true
|
4
4
|
|
5
5
|
module SmartMachine
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
module Logger
|
7
|
+
def logger
|
8
|
+
@logger ||= SmartMachine::Logger.logger_for(self.class.name)
|
9
|
+
end
|
10
10
|
|
11
|
-
|
12
|
-
|
11
|
+
# Use a hash class-ivar to cache a unique Logger per class:
|
12
|
+
@loggers = {}
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
14
|
+
def self.included(base)
|
15
|
+
class << base
|
16
|
+
def logger
|
17
|
+
@logger ||= SmartMachine::Logger.logger_for(self.name)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
class << self
|
23
|
+
def logger_for(classname)
|
24
|
+
@loggers[classname] ||= configure_logger_for(classname)
|
25
|
+
end
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
27
|
+
def configure_logger_for(classname)
|
28
|
+
logger = ::Logger.new($stdout)
|
29
|
+
logger.level = ::Logger.const_get("#{SmartMachine.config.logger_level}".upcase)
|
30
|
+
logger.progname = classname
|
31
|
+
logger
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|