generate systemd for postgres
This commit is contained in:
parent
ed7fc9aa7f
commit
29a9b08573
4 changed files with 63 additions and 24 deletions
|
@ -15,6 +15,17 @@ require 'ostruct'
|
|||
# dat command service zulip
|
||||
|
||||
module Execute
|
||||
class ServiceInstallContext
|
||||
attr_accessor :bin_dir, :data_dir, :version, :user_name
|
||||
|
||||
def initialize(bin_dir, data_dir, user_name, version)
|
||||
@bin_dir = bin_dir
|
||||
@data_dir = data_dir
|
||||
@user_name = user_name
|
||||
@version = version
|
||||
end
|
||||
end
|
||||
|
||||
def dependency(name)
|
||||
puts "Checking for #{name}..."
|
||||
|
||||
|
@ -34,15 +45,44 @@ module Execute
|
|||
Gem::Specification::find_all_by_name(name).any?
|
||||
end
|
||||
|
||||
def postgres
|
||||
def get_install_executor(name)
|
||||
require 'make'
|
||||
pdata = Make.context(name)
|
||||
bin_dir = pdata.get_prefix
|
||||
data_dir = "/data/#{pdata.name}/#{pdata.version.split(".").first}"
|
||||
service_install_context = ServiceInstallContext.new(
|
||||
bin_dir, data_dir, name, pdata.version
|
||||
)
|
||||
|
||||
case name
|
||||
when :postgresql
|
||||
require 'setup/postgresql'
|
||||
puts 'installing postgres'
|
||||
Setup::PostgreSQL.install
|
||||
-> { Setup::PostgreSQL.install(service_install_context) }
|
||||
# ->(context) {
|
||||
# Setup::PostgreSQL.install(context)
|
||||
# }
|
||||
else
|
||||
raise "Can't find the executor"
|
||||
end
|
||||
end
|
||||
|
||||
def execute_with_context(context)
|
||||
|
||||
end
|
||||
# def postgres
|
||||
# require 'setup/postgresql'
|
||||
# Setup::PostgreSQL.install
|
||||
# end
|
||||
|
||||
def service(name)
|
||||
executor = get_install_executor(name)
|
||||
#executor.call(service_install_context)
|
||||
executor.call
|
||||
exit -1
|
||||
|
||||
if block_given?
|
||||
context = OpenStruct.new
|
||||
# service context
|
||||
output = yield context
|
||||
puts output
|
||||
puts "context: #{context}"
|
||||
|
@ -62,16 +102,12 @@ module Execute
|
|||
end
|
||||
|
||||
def self.file(options)
|
||||
require 'make'
|
||||
puts Make.context("postgresql")
|
||||
|
||||
puts "options: #{options}"
|
||||
dsl = Object.new
|
||||
dsl.extend(Execute)
|
||||
|
||||
# Configfile
|
||||
path = File.join(Dir.pwd, options.name || "./Configfile")
|
||||
dsl.instance_eval(File.read(path), path)
|
||||
# Execute the config
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue