Module: MKIt
- Includes:
- ActiveRecord::Tasks
- Defined in:
- lib/mkit/ctypes.rb,
lib/mkit.rb,
lib/mkit/utils.rb,
lib/mkit/status.rb,
lib/mkit/version.rb,
lib/mkit/mkit_dns.rb,
lib/mkit/cmd_runner.rb,
lib/mkit/exceptions.rb,
lib/mkit/job_manager.rb,
lib/mkit/sagas/asaga.rb,
lib/mkit/ssl/easy_ssl.rb,
lib/mkit/config/config.rb,
lib/mkit/mkit_interface.rb,
lib/mkit/app/mkit_server.rb,
lib/mkit/workers/aworker.rb,
lib/mkit/cmd/shell_client.rb,
lib/mkit/client/http_client.rb,
lib/mkit/sagas/saga_manager.rb,
lib/mkit/workers/pod_worker.rb,
lib/mkit/app/helpers/haproxy.rb,
lib/mkit/client/mkitd_client.rb,
lib/mkit/pods/docker_listener.rb,
lib/mkit/sagas/create_pod_saga.rb,
lib/mkit/app/helpers/erb_helper.rb,
lib/mkit/workers/haproxy_worker.rb,
lib/mkit/workers/service_worker.rb,
lib/mkit/workers/worker_manager.rb,
lib/mkit/app/helpers/pods_helper.rb,
lib/mkit/client/websocket_client.rb,
lib/mkit/pods/docker_exec_command.rb,
lib/mkit/pods/docker_log_listener.rb,
lib/mkit/app/helpers/docker_helper.rb,
lib/mkit/app/helpers/params_helper.rb,
lib/mkit/app/helpers/services_helper.rb,
lib/mkit/client/log_websocket_client.rb,
lib/mkit/config/load_default_configs.rb,
lib/mkit/app/helpers/interface_helper.rb,
lib/mkit/client/console_websocket_client.rb
Overview
Defined Under Namespace
Modules: CType, Config, DockerHelper, ERBHelper, HAProxy, Initializers, InterfaceHelper, ParamsHelper, PodsHelper, PoolStatus, ServicesHelper, Status, Templates, Utils
Classes: ASaga, AWorker, AppAlreadyDeployedException, BaseException, CmdRunner, CmdRunnerException, ConsoleWebSocketClient, CreatePodSaga, DNS, DockerExecCommand, DockerListener, DockerLogListener, EasySSL, Error, ExitShell, HAProxyWorker, HttpClient, Interface, InvalidPortMappingTypeException, InvalidPortsConfiguration, JobManager, LogWebSocketClient, MKItCType, MKItStatus, MKItdClient, PodNotFoundException, PodWorker, PoolExaustedException, SagaManager, Server, ServiceAlreadyExists, ServiceNameMismatch, ServiceNotFoundException, ServiceWorker, ShellClient, StopThread, WebSocketClient, WorkerManager
Constant Summary
collapse
- System =
Dry::Container.new
- VERSION =
"0.9.0"
Class Method Summary
collapse
Class Method Details
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
|
# File 'lib/mkit.rb', line 42
def self.configure(options:)
@root = MKIt::Utils.root
@options = options
MKItLogger.debug!
@config_dir = if ENV['RACK_ENV'] != 'development'
@options[:config_dir].nil? ? '/etc/mkit' : @options[:config_dir]
else
@options[:config_dir].nil? ? "#{@root}/config" : @options[:config_dir]
end
MKIt::Utils.set_config_dir(@config_dir)
@bind = options[:bind] ||= 'localhost'
@port = options[:port] ||= 4567
@ssl = options[:ssl].nil? ? true : options[:ssl] && true
@verify_peer = options[:verify_peer].nil? ? false : options[:verify_peer] && true
@cert_chain_file = options[:cert_chain_file] ||= "#{@config_dir}/#{MKIt::Utils::MKIT_CRT}"
@private_key_file = options[:private_key_file] ||= "#{@config_dir}/#{MKIt::Utils::MKIT_KEY}"
if ENV['RACK_ENV'] != 'development' || !options[:config_dir].nil?
check_config_files = false
unless File.exist?(@config_dir)
FileUtils.mkdir_p(@config_dir)
check_config_files = true
end
FileUtils.mkdir_p('/var/lib/mkitd') unless File.exist?('/var/lib/mkitd')
FileUtils.cp("#{@root}/config/mkit_config.yml", @config_dir) unless File.exist?("#{@config_dir}/mkit_config.yml")
FileUtils.cp("#{@root}/config/database.yml", @config_dir) unless File.exist?("#{@config_dir}/database.yml")
FileUtils.cp("#{@root}/config/mkitd_config.sh", @config_dir) unless File.exist?("#{@config_dir}/mkitd_config.sh")
if check_config_files
MKItLogger.info "Configuration files copied to #{@config_dir}. Please check it and restart."
exit
end
end
MKIt::Initializers.load_my_configuration
MKIt::EasySSL.create_self_certificate(@config_dir)
FileUtils.mkdir_p(MKIt::Config.mkit.haproxy.config_dir)
unless File.exist?("#{MKIt::Config.mkit.haproxy.config_dir}/0000_defaults.cfg")
FileUtils.cp(
"#{MKIt::Utils.root}/lib/mkit/app/templates/haproxy/0000_defaults.cfg",
MKIt::Config.mkit.haproxy.config_dir
)
end
DatabaseTasks.database_configuration = MKIt::Utils.load_db_config
DatabaseTasks.env = MKIt::Config.mkit.database.env
DatabaseTasks.migrations_paths = ["#{@root}/db/migrate"]
DatabaseTasks.db_dir = 'db'
DatabaseTasks.root = @root
end
|
.establish_db_connection ⇒ Object
121
122
123
124
125
126
127
128
129
|
# File 'lib/mkit.rb', line 121
def self.establish_db_connection
ActiveRecord::Base.establish_connection(DatabaseTasks.database_configuration[DatabaseTasks.env])
ActiveRecord::Base.connection.migration_context.migrations_paths.clear
ActiveRecord::Base.connection.migration_context.migrations_paths << "#{@root}/db/migrate"
MKItLogger.debug "database_tasks migration paths #{DatabaseTasks.migrations_paths}"
MKItLogger.debug "active_record_base migration_paths #{ActiveRecord::Base.connection.migration_context.migrations_paths.inspect}"
MKItLogger.debug "active_record_base configurations #{ActiveRecord::Base.configurations.inspect}"
MKItLogger.debug "active_record_base conn_db_config #{ActiveRecord::Base.connection_db_config.inspect}"
end
|
.migrate ⇒ Object
131
132
133
134
135
|
# File 'lib/mkit.rb', line 131
def self.migrate
if ActiveRecord::Base.connection.migration_context.needs_migration?
ActiveRecord::Base.connection.migration_context.migrate
end
end
|
.options(server) ⇒ Object
107
108
109
110
111
112
113
114
115
116
117
118
119
|
# File 'lib/mkit.rb', line 107
def self.options(server)
if @ssl
ssl_options = {
private_key_file: @private_key_file,
cert_chain_file: @cert_chain_file,
verify_peer: @verify_peer
}
server.ssl = true
server.ssl_options = ssl_options
end
server.backend.port = @port
server.backend.host = @bind
end
|
.restore_operation ⇒ Object
137
138
139
140
141
142
143
144
145
146
147
148
|
# File 'lib/mkit.rb', line 137
def self.restore_operation
MKItLogger.info 'restoring operations...'
Service.all.each do |srv|
srv.deploy_network
srv.update_status!
end
MKItLogger.debug 'restarting proxy...'
MKIt::HAProxy.restart
end
|
.startup(options: {}) ⇒ Object