Added additional params template for backend service

This commit is contained in:
Jakub Matys 2018-07-31 10:30:11 +02:00
parent a7101b3ca5
commit a636a3197d
19 changed files with 44 additions and 24 deletions

View File

@ -15,6 +15,7 @@ PIDFile=/run/{{.Coin.Alias}}/{{.Coin.Alias}}.pid
{{else -}} {{else -}}
Type=simple Type=simple
{{end}} {{end}}
{{template "Backend.ServiceAdditionalParamsTemplate" .}}
# Resource limits # Resource limits
LimitNOFILE=500000 LimitNOFILE=500000

View File

@ -48,23 +48,24 @@ type Config struct {
MessageQueueBindingTemplate string `json:"message_queue_binding_template"` MessageQueueBindingTemplate string `json:"message_queue_binding_template"`
} `json:"ipc"` } `json:"ipc"`
Backend struct { Backend struct {
PackageName string `json:"package_name"` PackageName string `json:"package_name"`
PackageRevision string `json:"package_revision"` PackageRevision string `json:"package_revision"`
SystemUser string `json:"system_user"` SystemUser string `json:"system_user"`
Version string `json:"version"` Version string `json:"version"`
BinaryURL string `json:"binary_url"` BinaryURL string `json:"binary_url"`
VerificationType string `json:"verification_type"` VerificationType string `json:"verification_type"`
VerificationSource string `json:"verification_source"` VerificationSource string `json:"verification_source"`
ExtractCommand string `json:"extract_command"` ExtractCommand string `json:"extract_command"`
ExcludeFiles []string `json:"exclude_files"` ExcludeFiles []string `json:"exclude_files"`
ExecCommandTemplate string `json:"exec_command_template"` ExecCommandTemplate string `json:"exec_command_template"`
LogrotateFilesTemplate string `json:"logrotate_files_template"` LogrotateFilesTemplate string `json:"logrotate_files_template"`
PostinstScriptTemplate string `json:"postinst_script_template"` PostinstScriptTemplate string `json:"postinst_script_template"`
ServiceType string `json:"service_type"` ServiceType string `json:"service_type"`
ProtectMemory bool `json:"protect_memory"` ServiceAdditionalParamsTemplate string `json:"service_additional_params_template"`
Mainnet bool `json:"mainnet"` ProtectMemory bool `json:"protect_memory"`
ConfigFile string `json:"config_file"` Mainnet bool `json:"mainnet"`
AdditionalParams interface{} `json:"additional_params"` ConfigFile string `json:"config_file"`
AdditionalParams interface{} `json:"additional_params"`
} `json:"backend"` } `json:"backend"`
Blockbook struct { Blockbook struct {
PackageName string `json:"package_name"` PackageName string `json:"package_name"`
@ -95,13 +96,14 @@ func jsonToString(msg json.RawMessage) (string, error) {
func (c *Config) ParseTemplate() *template.Template { func (c *Config) ParseTemplate() *template.Template {
templates := map[string]string{ templates := map[string]string{
"IPC.RPCURLTemplate": c.IPC.RPCURLTemplate, "IPC.RPCURLTemplate": c.IPC.RPCURLTemplate,
"IPC.MessageQueueBindingTemplate": c.IPC.MessageQueueBindingTemplate, "IPC.MessageQueueBindingTemplate": c.IPC.MessageQueueBindingTemplate,
"Backend.ExecCommandTemplate": c.Backend.ExecCommandTemplate, "Backend.ExecCommandTemplate": c.Backend.ExecCommandTemplate,
"Backend.LogrotateFilesTemplate": c.Backend.LogrotateFilesTemplate, "Backend.LogrotateFilesTemplate": c.Backend.LogrotateFilesTemplate,
"Backend.PostinstScriptTemplate": c.Backend.PostinstScriptTemplate, "Backend.PostinstScriptTemplate": c.Backend.PostinstScriptTemplate,
"Blockbook.InternalBindingTemplate": c.Blockbook.InternalBindingTemplate, "Backend.ServiceAdditionalParamsTemplate": c.Backend.ServiceAdditionalParamsTemplate,
"Blockbook.PublicBindingTemplate": c.Blockbook.PublicBindingTemplate, "Blockbook.InternalBindingTemplate": c.Blockbook.InternalBindingTemplate,
"Blockbook.PublicBindingTemplate": c.Blockbook.PublicBindingTemplate,
} }
funcMap := template.FuncMap{ funcMap := template.FuncMap{

View File

@ -34,6 +34,7 @@
"logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/*.log", "logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/*.log",
"postinst_script_template": "", "postinst_script_template": "",
"service_type": "forking", "service_type": "forking",
"service_additional_params_template": "",
"protect_memory": true, "protect_memory": true,
"mainnet": true, "mainnet": true,
"config_file": "bitcoin.conf" "config_file": "bitcoin.conf"

View File

@ -34,6 +34,7 @@
"logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/testnet3/*.log", "logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/testnet3/*.log",
"postinst_script_template": "", "postinst_script_template": "",
"service_type": "forking", "service_type": "forking",
"service_additional_params_template": "",
"protect_memory": true, "protect_memory": true,
"mainnet": false, "mainnet": false,
"config_file": "bitcoin.conf" "config_file": "bitcoin.conf"

View File

@ -34,6 +34,7 @@
"logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/*.log", "logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/*.log",
"postinst_script_template": "", "postinst_script_template": "",
"service_type": "forking", "service_type": "forking",
"service_additional_params_template": "",
"protect_memory": true, "protect_memory": true,
"mainnet": true, "mainnet": true,
"config_file": "bitcoin.conf", "config_file": "bitcoin.conf",

View File

@ -34,6 +34,7 @@
"logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/*.log", "logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/*.log",
"postinst_script_template": "", "postinst_script_template": "",
"service_type": "forking", "service_type": "forking",
"service_additional_params_template": "",
"protect_memory": true, "protect_memory": true,
"mainnet": true, "mainnet": true,
"config_file": "bitcoin.conf", "config_file": "bitcoin.conf",

View File

@ -34,6 +34,7 @@
"logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/testnet3/*.log", "logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/testnet3/*.log",
"postinst_script_template": "", "postinst_script_template": "",
"service_type": "forking", "service_type": "forking",
"service_additional_params_template": "",
"protect_memory": true, "protect_memory": true,
"mainnet": false, "mainnet": false,
"config_file": "bitcoin.conf", "config_file": "bitcoin.conf",

View File

@ -34,6 +34,7 @@
"logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/*.log", "logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/*.log",
"postinst_script_template": "", "postinst_script_template": "",
"service_type": "forking", "service_type": "forking",
"service_additional_params_template": "",
"protect_memory": true, "protect_memory": true,
"mainnet": true, "mainnet": true,
"config_file": "bitcoin.conf", "config_file": "bitcoin.conf",

View File

@ -34,6 +34,7 @@
"logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/testnet3/*.log", "logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/testnet3/*.log",
"postinst_script_template": "", "postinst_script_template": "",
"service_type": "forking", "service_type": "forking",
"service_additional_params_template": "",
"protect_memory": true, "protect_memory": true,
"mainnet": false, "mainnet": false,
"config_file": "bitcoin.conf", "config_file": "bitcoin.conf",

View File

@ -34,6 +34,7 @@
"logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/*.log", "logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/*.log",
"postinst_script_template": "", "postinst_script_template": "",
"service_type": "forking", "service_type": "forking",
"service_additional_params_template": "",
"protect_memory": false, "protect_memory": false,
"mainnet": true, "mainnet": true,
"config_file": "bitcoin.conf", "config_file": "bitcoin.conf",

View File

@ -29,6 +29,7 @@
"logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/{{.Coin.Alias}}.log", "logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/{{.Coin.Alias}}.log",
"postinst_script_template": "", "postinst_script_template": "",
"service_type": "simple", "service_type": "simple",
"service_additional_params_template": "",
"protect_memory": true, "protect_memory": true,
"mainnet": true, "mainnet": true,
"config_file": "" "config_file": ""

View File

@ -29,6 +29,7 @@
"logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/{{.Coin.Alias}}.log", "logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/{{.Coin.Alias}}.log",
"postinst_script_template": "", "postinst_script_template": "",
"service_type": "simple", "service_type": "simple",
"service_additional_params_template": "",
"protect_memory": true, "protect_memory": true,
"mainnet": false, "mainnet": false,
"config_file": "" "config_file": ""

View File

@ -34,6 +34,7 @@
"logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/*.log", "logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/*.log",
"postinst_script_template": "", "postinst_script_template": "",
"service_type": "forking", "service_type": "forking",
"service_additional_params_template": "",
"protect_memory": true, "protect_memory": true,
"mainnet": true, "mainnet": true,
"config_file": "bitcoin.conf", "config_file": "bitcoin.conf",

View File

@ -34,6 +34,7 @@
"logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/testnet4/*.log", "logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/testnet4/*.log",
"postinst_script_template": "", "postinst_script_template": "",
"service_type": "forking", "service_type": "forking",
"service_additional_params_template": "",
"protect_memory": true, "protect_memory": true,
"mainnet": false, "mainnet": false,
"config_file": "bitcoin.conf", "config_file": "bitcoin.conf",

View File

@ -34,6 +34,7 @@
"logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/*.log", "logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/*.log",
"postinst_script_template": "", "postinst_script_template": "",
"service_type": "forking", "service_type": "forking",
"service_additional_params_template": "",
"protect_memory": true, "protect_memory": true,
"mainnet": true, "mainnet": true,
"config_file": "bitcoin.conf", "config_file": "bitcoin.conf",

View File

@ -32,6 +32,7 @@
"logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/*.log", "logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/*.log",
"postinst_script_template": "", "postinst_script_template": "",
"service_type": "forking", "service_type": "forking",
"service_additional_params_template": "",
"protect_memory": true, "protect_memory": true,
"mainnet": true, "mainnet": true,
"config_file": "bitcoin.conf", "config_file": "bitcoin.conf",

View File

@ -32,6 +32,7 @@
"logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/testnet3/*.log", "logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/testnet3/*.log",
"postinst_script_template": "", "postinst_script_template": "",
"service_type": "forking", "service_type": "forking",
"service_additional_params_template": "",
"protect_memory": true, "protect_memory": true,
"mainnet": false, "mainnet": false,
"config_file": "bitcoin.conf", "config_file": "bitcoin.conf",

View File

@ -32,6 +32,7 @@
"logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/*.log", "logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/*.log",
"postinst_script_template": "HOME={{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend {{.Env.BackendInstallPath}}/{{.Coin.Alias}}/bin/zcash-fetch-params", "postinst_script_template": "HOME={{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend {{.Env.BackendInstallPath}}/{{.Coin.Alias}}/bin/zcash-fetch-params",
"service_type": "forking", "service_type": "forking",
"service_additional_params_template": "Environment=\"HOME={{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend\"",
"protect_memory": false, "protect_memory": false,
"mainnet": true, "mainnet": true,
"config_file": "bitcoin.conf", "config_file": "bitcoin.conf",

View File

@ -32,6 +32,7 @@
"logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/testnet3/*.log", "logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/testnet3/*.log",
"postinst_script_template": "HOME={{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend {{.Env.BackendInstallPath}}/{{.Coin.Alias}}/bin/zcash-fetch-params --testnet", "postinst_script_template": "HOME={{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend {{.Env.BackendInstallPath}}/{{.Coin.Alias}}/bin/zcash-fetch-params --testnet",
"service_type": "forking", "service_type": "forking",
"service_additional_params_template": "Environment=\"HOME={{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend\"",
"protect_memory": false, "protect_memory": false,
"mainnet": false, "mainnet": false,
"config_file": "bitcoin.conf", "config_file": "bitcoin.conf",