generate systemd for postgres
This commit is contained in:
parent
ed7fc9aa7f
commit
29a9b08573
4 changed files with 63 additions and 24 deletions
|
@ -8,7 +8,7 @@ Type=notify
|
||||||
User=postgres
|
User=postgres
|
||||||
Group=services
|
Group=services
|
||||||
|
|
||||||
ExecStart=<%= prefix %>/bin/postgres -D <%= database_path %>/data
|
ExecStart=<%= postgres_bin %> -D <%= database_dir %>/data
|
||||||
ExecReload=/bin/kill -HUP $MAINPID
|
ExecReload=/bin/kill -HUP $MAINPID
|
||||||
KillMode=mixed
|
KillMode=mixed
|
||||||
TimeoutSec=300
|
TimeoutSec=300
|
|
@ -15,6 +15,17 @@ require 'ostruct'
|
||||||
# dat command service zulip
|
# dat command service zulip
|
||||||
|
|
||||||
module Execute
|
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)
|
def dependency(name)
|
||||||
puts "Checking for #{name}..."
|
puts "Checking for #{name}..."
|
||||||
|
|
||||||
|
@ -34,15 +45,44 @@ module Execute
|
||||||
Gem::Specification::find_all_by_name(name).any?
|
Gem::Specification::find_all_by_name(name).any?
|
||||||
end
|
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'
|
require 'setup/postgresql'
|
||||||
puts 'installing postgres'
|
-> { Setup::PostgreSQL.install(service_install_context) }
|
||||||
Setup::PostgreSQL.install
|
# ->(context) {
|
||||||
|
# Setup::PostgreSQL.install(context)
|
||||||
|
# }
|
||||||
|
else
|
||||||
|
raise "Can't find the executor"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def execute_with_context(context)
|
||||||
|
|
||||||
|
end
|
||||||
|
# def postgres
|
||||||
|
# require 'setup/postgresql'
|
||||||
|
# Setup::PostgreSQL.install
|
||||||
|
# end
|
||||||
|
|
||||||
def service(name)
|
def service(name)
|
||||||
|
executor = get_install_executor(name)
|
||||||
|
#executor.call(service_install_context)
|
||||||
|
executor.call
|
||||||
|
exit -1
|
||||||
|
|
||||||
if block_given?
|
if block_given?
|
||||||
context = OpenStruct.new
|
context = OpenStruct.new
|
||||||
|
# service context
|
||||||
output = yield context
|
output = yield context
|
||||||
puts output
|
puts output
|
||||||
puts "context: #{context}"
|
puts "context: #{context}"
|
||||||
|
@ -62,16 +102,12 @@ module Execute
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.file(options)
|
def self.file(options)
|
||||||
require 'make'
|
|
||||||
puts Make.context("postgresql")
|
|
||||||
|
|
||||||
puts "options: #{options}"
|
|
||||||
dsl = Object.new
|
dsl = Object.new
|
||||||
dsl.extend(Execute)
|
dsl.extend(Execute)
|
||||||
|
|
||||||
# Configfile
|
# Configfile
|
||||||
path = File.join(Dir.pwd, options.name || "./Configfile")
|
path = File.join(Dir.pwd, options.name || "./Configfile")
|
||||||
dsl.instance_eval(File.read(path), path)
|
dsl.instance_eval(File.read(path), path)
|
||||||
# Execute the config
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
|
|
||||||
module Setup
|
module Setup
|
||||||
require_relative '../templates'
|
require_relative '../templates'
|
||||||
|
# dat execute postgres
|
||||||
|
# example.rcp
|
||||||
|
|
||||||
module PostgreSQL
|
module PostgreSQL
|
||||||
extend Templates
|
extend Templates
|
||||||
|
|
||||||
|
@ -9,26 +11,25 @@ module Setup
|
||||||
|
|
||||||
# attr_accessor :te
|
# attr_accessor :te
|
||||||
|
|
||||||
def self.init_db
|
def self.init_db(context)
|
||||||
system(" -D /opt/pgsql/16/data")
|
system(" -D /opt/pgsql/16/data")
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.make_config
|
def self.install(context)
|
||||||
pg_hba = render("pg_hba.conf")
|
# puts context.bin_dir
|
||||||
|
#make_config
|
||||||
# test = render("test", te: "This is a test string")
|
# pg_hba = render("pg_hba.conf")
|
||||||
posgresql_conf = render("postgresql")
|
#
|
||||||
|
# # test = render("test", te: "This is a test string")
|
||||||
|
# posgresql_conf = render("postgresql")
|
||||||
service = render(
|
service = render(
|
||||||
"postgresql.service",
|
"postgresql.service",
|
||||||
prefix: "/pkg/postgresql/REL_17_5/",
|
postgres_bin: File.join(context.bin_dir, "/bin/postgres"),
|
||||||
version: "16.5",
|
version: context.version,
|
||||||
data_url: "/data/postgresql/16/"
|
database_dir: context.data_dir
|
||||||
)
|
)
|
||||||
puts test
|
puts service
|
||||||
end
|
|
||||||
|
|
||||||
def self.install
|
|
||||||
make_config
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,6 +12,8 @@ packages:
|
||||||
- libedit-dev
|
- libedit-dev
|
||||||
|
|
||||||
repository:
|
repository:
|
||||||
|
# Original repository
|
||||||
|
# https://git.postgresql.org/gitweb/?p=postgresql.git
|
||||||
url: https://github.com/postgres/postgres.git
|
url: https://github.com/postgres/postgres.git
|
||||||
branch: REL_17_5
|
branch: REL_17_5
|
||||||
version: 17.5
|
version: 17.5
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue