From a636a3197d83a9385ed0b1d69d096f380789faa2 Mon Sep 17 00:00:00 2001 From: Jakub Matys Date: Tue, 31 Jul 2018 10:30:11 +0200 Subject: [PATCH] Added additional params template for backend service --- build/templates/backend/debian/service | 1 + build/templates/generate.go | 50 +++++++++++---------- configs/coins/bcash.json | 1 + configs/coins/bcash_testnet.json | 1 + configs/coins/bgold.json | 1 + configs/coins/bitcoin.json | 1 + configs/coins/bitcoin_testnet.json | 1 + configs/coins/dash.json | 1 + configs/coins/dash_testnet.json | 1 + configs/coins/dogecoin.json | 1 + configs/coins/ethereum.json | 1 + configs/coins/ethereum_testnet_ropsten.json | 1 + configs/coins/litecoin.json | 1 + configs/coins/litecoin_testnet.json | 1 + configs/coins/namecoin.json | 1 + configs/coins/vertcoin.json | 1 + configs/coins/vertcoin_testnet.json | 1 + configs/coins/zcash.json | 1 + configs/coins/zcash_testnet.json | 1 + 19 files changed, 44 insertions(+), 24 deletions(-) diff --git a/build/templates/backend/debian/service b/build/templates/backend/debian/service index ec6deed3..b494c22c 100644 --- a/build/templates/backend/debian/service +++ b/build/templates/backend/debian/service @@ -15,6 +15,7 @@ PIDFile=/run/{{.Coin.Alias}}/{{.Coin.Alias}}.pid {{else -}} Type=simple {{end}} +{{template "Backend.ServiceAdditionalParamsTemplate" .}} # Resource limits LimitNOFILE=500000 diff --git a/build/templates/generate.go b/build/templates/generate.go index 949577db..aa4bc8e3 100644 --- a/build/templates/generate.go +++ b/build/templates/generate.go @@ -48,23 +48,24 @@ type Config struct { MessageQueueBindingTemplate string `json:"message_queue_binding_template"` } `json:"ipc"` Backend struct { - PackageName string `json:"package_name"` - PackageRevision string `json:"package_revision"` - SystemUser string `json:"system_user"` - Version string `json:"version"` - BinaryURL string `json:"binary_url"` - VerificationType string `json:"verification_type"` - VerificationSource string `json:"verification_source"` - ExtractCommand string `json:"extract_command"` - ExcludeFiles []string `json:"exclude_files"` - ExecCommandTemplate string `json:"exec_command_template"` - LogrotateFilesTemplate string `json:"logrotate_files_template"` - PostinstScriptTemplate string `json:"postinst_script_template"` - ServiceType string `json:"service_type"` - ProtectMemory bool `json:"protect_memory"` - Mainnet bool `json:"mainnet"` - ConfigFile string `json:"config_file"` - AdditionalParams interface{} `json:"additional_params"` + PackageName string `json:"package_name"` + PackageRevision string `json:"package_revision"` + SystemUser string `json:"system_user"` + Version string `json:"version"` + BinaryURL string `json:"binary_url"` + VerificationType string `json:"verification_type"` + VerificationSource string `json:"verification_source"` + ExtractCommand string `json:"extract_command"` + ExcludeFiles []string `json:"exclude_files"` + ExecCommandTemplate string `json:"exec_command_template"` + LogrotateFilesTemplate string `json:"logrotate_files_template"` + PostinstScriptTemplate string `json:"postinst_script_template"` + ServiceType string `json:"service_type"` + ServiceAdditionalParamsTemplate string `json:"service_additional_params_template"` + ProtectMemory bool `json:"protect_memory"` + Mainnet bool `json:"mainnet"` + ConfigFile string `json:"config_file"` + AdditionalParams interface{} `json:"additional_params"` } `json:"backend"` Blockbook struct { PackageName string `json:"package_name"` @@ -95,13 +96,14 @@ func jsonToString(msg json.RawMessage) (string, error) { func (c *Config) ParseTemplate() *template.Template { templates := map[string]string{ - "IPC.RPCURLTemplate": c.IPC.RPCURLTemplate, - "IPC.MessageQueueBindingTemplate": c.IPC.MessageQueueBindingTemplate, - "Backend.ExecCommandTemplate": c.Backend.ExecCommandTemplate, - "Backend.LogrotateFilesTemplate": c.Backend.LogrotateFilesTemplate, - "Backend.PostinstScriptTemplate": c.Backend.PostinstScriptTemplate, - "Blockbook.InternalBindingTemplate": c.Blockbook.InternalBindingTemplate, - "Blockbook.PublicBindingTemplate": c.Blockbook.PublicBindingTemplate, + "IPC.RPCURLTemplate": c.IPC.RPCURLTemplate, + "IPC.MessageQueueBindingTemplate": c.IPC.MessageQueueBindingTemplate, + "Backend.ExecCommandTemplate": c.Backend.ExecCommandTemplate, + "Backend.LogrotateFilesTemplate": c.Backend.LogrotateFilesTemplate, + "Backend.PostinstScriptTemplate": c.Backend.PostinstScriptTemplate, + "Backend.ServiceAdditionalParamsTemplate": c.Backend.ServiceAdditionalParamsTemplate, + "Blockbook.InternalBindingTemplate": c.Blockbook.InternalBindingTemplate, + "Blockbook.PublicBindingTemplate": c.Blockbook.PublicBindingTemplate, } funcMap := template.FuncMap{ diff --git a/configs/coins/bcash.json b/configs/coins/bcash.json index e876e7f2..e1bfe518 100644 --- a/configs/coins/bcash.json +++ b/configs/coins/bcash.json @@ -34,6 +34,7 @@ "logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/*.log", "postinst_script_template": "", "service_type": "forking", + "service_additional_params_template": "", "protect_memory": true, "mainnet": true, "config_file": "bitcoin.conf" diff --git a/configs/coins/bcash_testnet.json b/configs/coins/bcash_testnet.json index 5f1b4675..af58f66a 100644 --- a/configs/coins/bcash_testnet.json +++ b/configs/coins/bcash_testnet.json @@ -34,6 +34,7 @@ "logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/testnet3/*.log", "postinst_script_template": "", "service_type": "forking", + "service_additional_params_template": "", "protect_memory": true, "mainnet": false, "config_file": "bitcoin.conf" diff --git a/configs/coins/bgold.json b/configs/coins/bgold.json index f27149d4..5f7b245f 100644 --- a/configs/coins/bgold.json +++ b/configs/coins/bgold.json @@ -34,6 +34,7 @@ "logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/*.log", "postinst_script_template": "", "service_type": "forking", + "service_additional_params_template": "", "protect_memory": true, "mainnet": true, "config_file": "bitcoin.conf", diff --git a/configs/coins/bitcoin.json b/configs/coins/bitcoin.json index fedfb0c2..0fa0f907 100644 --- a/configs/coins/bitcoin.json +++ b/configs/coins/bitcoin.json @@ -34,6 +34,7 @@ "logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/*.log", "postinst_script_template": "", "service_type": "forking", + "service_additional_params_template": "", "protect_memory": true, "mainnet": true, "config_file": "bitcoin.conf", diff --git a/configs/coins/bitcoin_testnet.json b/configs/coins/bitcoin_testnet.json index 069f4194..d949cf5f 100644 --- a/configs/coins/bitcoin_testnet.json +++ b/configs/coins/bitcoin_testnet.json @@ -34,6 +34,7 @@ "logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/testnet3/*.log", "postinst_script_template": "", "service_type": "forking", + "service_additional_params_template": "", "protect_memory": true, "mainnet": false, "config_file": "bitcoin.conf", diff --git a/configs/coins/dash.json b/configs/coins/dash.json index f0a16660..d2895671 100644 --- a/configs/coins/dash.json +++ b/configs/coins/dash.json @@ -34,6 +34,7 @@ "logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/*.log", "postinst_script_template": "", "service_type": "forking", + "service_additional_params_template": "", "protect_memory": true, "mainnet": true, "config_file": "bitcoin.conf", diff --git a/configs/coins/dash_testnet.json b/configs/coins/dash_testnet.json index c5162101..38407e37 100644 --- a/configs/coins/dash_testnet.json +++ b/configs/coins/dash_testnet.json @@ -34,6 +34,7 @@ "logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/testnet3/*.log", "postinst_script_template": "", "service_type": "forking", + "service_additional_params_template": "", "protect_memory": true, "mainnet": false, "config_file": "bitcoin.conf", diff --git a/configs/coins/dogecoin.json b/configs/coins/dogecoin.json index 39c4350f..cb9b7a68 100644 --- a/configs/coins/dogecoin.json +++ b/configs/coins/dogecoin.json @@ -34,6 +34,7 @@ "logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/*.log", "postinst_script_template": "", "service_type": "forking", + "service_additional_params_template": "", "protect_memory": false, "mainnet": true, "config_file": "bitcoin.conf", diff --git a/configs/coins/ethereum.json b/configs/coins/ethereum.json index 98f0b3e2..c51ccec9 100644 --- a/configs/coins/ethereum.json +++ b/configs/coins/ethereum.json @@ -29,6 +29,7 @@ "logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/{{.Coin.Alias}}.log", "postinst_script_template": "", "service_type": "simple", + "service_additional_params_template": "", "protect_memory": true, "mainnet": true, "config_file": "" diff --git a/configs/coins/ethereum_testnet_ropsten.json b/configs/coins/ethereum_testnet_ropsten.json index 6b3637c9..cb241065 100644 --- a/configs/coins/ethereum_testnet_ropsten.json +++ b/configs/coins/ethereum_testnet_ropsten.json @@ -29,6 +29,7 @@ "logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/{{.Coin.Alias}}.log", "postinst_script_template": "", "service_type": "simple", + "service_additional_params_template": "", "protect_memory": true, "mainnet": false, "config_file": "" diff --git a/configs/coins/litecoin.json b/configs/coins/litecoin.json index 75da9905..9279940f 100644 --- a/configs/coins/litecoin.json +++ b/configs/coins/litecoin.json @@ -34,6 +34,7 @@ "logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/*.log", "postinst_script_template": "", "service_type": "forking", + "service_additional_params_template": "", "protect_memory": true, "mainnet": true, "config_file": "bitcoin.conf", diff --git a/configs/coins/litecoin_testnet.json b/configs/coins/litecoin_testnet.json index 7649ea11..819ae8c0 100644 --- a/configs/coins/litecoin_testnet.json +++ b/configs/coins/litecoin_testnet.json @@ -34,6 +34,7 @@ "logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/testnet4/*.log", "postinst_script_template": "", "service_type": "forking", + "service_additional_params_template": "", "protect_memory": true, "mainnet": false, "config_file": "bitcoin.conf", diff --git a/configs/coins/namecoin.json b/configs/coins/namecoin.json index ff770c16..754ee628 100644 --- a/configs/coins/namecoin.json +++ b/configs/coins/namecoin.json @@ -34,6 +34,7 @@ "logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/*.log", "postinst_script_template": "", "service_type": "forking", + "service_additional_params_template": "", "protect_memory": true, "mainnet": true, "config_file": "bitcoin.conf", diff --git a/configs/coins/vertcoin.json b/configs/coins/vertcoin.json index 3f6199b8..d68a0a0f 100644 --- a/configs/coins/vertcoin.json +++ b/configs/coins/vertcoin.json @@ -32,6 +32,7 @@ "logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/*.log", "postinst_script_template": "", "service_type": "forking", + "service_additional_params_template": "", "protect_memory": true, "mainnet": true, "config_file": "bitcoin.conf", diff --git a/configs/coins/vertcoin_testnet.json b/configs/coins/vertcoin_testnet.json index 94cab0d4..314929c3 100644 --- a/configs/coins/vertcoin_testnet.json +++ b/configs/coins/vertcoin_testnet.json @@ -32,6 +32,7 @@ "logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/testnet3/*.log", "postinst_script_template": "", "service_type": "forking", + "service_additional_params_template": "", "protect_memory": true, "mainnet": false, "config_file": "bitcoin.conf", diff --git a/configs/coins/zcash.json b/configs/coins/zcash.json index 2ce82994..ab65b246 100644 --- a/configs/coins/zcash.json +++ b/configs/coins/zcash.json @@ -32,6 +32,7 @@ "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", "service_type": "forking", + "service_additional_params_template": "Environment=\"HOME={{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend\"", "protect_memory": false, "mainnet": true, "config_file": "bitcoin.conf", diff --git a/configs/coins/zcash_testnet.json b/configs/coins/zcash_testnet.json index 77440417..c2793c96 100644 --- a/configs/coins/zcash_testnet.json +++ b/configs/coins/zcash_testnet.json @@ -32,6 +32,7 @@ "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", "service_type": "forking", + "service_additional_params_template": "Environment=\"HOME={{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend\"", "protect_memory": false, "mainnet": false, "config_file": "bitcoin.conf",