hashicorp / consul-template

Template rendering, notifier, and supervisor for @HashiCorp Consul and Vault data.
https://www.hashicorp.com/
Mozilla Public License 2.0
4.76k stars 781 forks source link

[ERR] (cli) child process died with exit code 0 #1281

Closed dibyajyotiron closed 5 years ago

dibyajyotiron commented 5 years ago

Consul Template version

0.21.3

Configuration

consul {
  #address = "127.0.0.1:8501"  
  retry {
    enabled = true
    attempts = 20
    backoff = "1000ms"
    max_backoff = "1000ms"
  }
  ssl {
   enabled = true
   verify = false
   cert = "/home/ubuntu/consul-client/consul.d/certificates/sh_primary-client-consul-0.pem"
   key = "/home/ubuntu/consul-client/consul.d/certificates/sh_primary-client-consul-0-key.pem"
   ca_cert = "/home/ubuntu/consul-client/consul.d/certificates/consul-agent-ca.pem"
  }
  token = "CONSUL_TOKEN"
}
#reload_signal = "SIGHUP"
exec {
  command = "chmod +x /home/ubuntu/consul-client/consul-template/scripts/staging/restart-pm2.sh && /home/ubuntu/consul-client/consul-template/scripts/staging/restart-pm2.sh"
  #command = "/bin/bash -c 'pm2 restart $dev'"
  #reload_signal = "SIGHUP"
}

log_level = "trace"
template {
 source = "/home/ubuntu/consul-client/consul-template/config-development.tpl"
 destination = "/home/ubuntu/therm_backend/staging/config/development.json"
}
{{ key "/therm/development" }}

Command

sudo consul-template -config=config-development.hcl -consul-token=$token_therm

Debug output

2019/09/16 13:14:08.305263 [INFO] consul-template v0.21.3 (3574c7c1)
2019/09/16 13:14:08.305287 [INFO] (runner) creating new runner (dry: false, once: false)
2019/09/16 13:14:08.305566 [DEBUG] (runner) final config: {"Consul":{"Address":"x.x.x.x:8501","Auth":{"Enabled":false,"Username":"","Password":""},"Retry":{"Attempts":20,"Backoff":1000000000,"MaxBackoff":1000000000,"Enabled":true},"SSL":{"CaCert":"/home/ubuntu/consul-client/consul.d/certificates/consul-agent-ca.pem","CaPath":"","Cert":"/home/ubuntu/consul-client/consul.d/certificates/sh_primary-client-consul-0.pem","Enabled":true,"Key":"/home/ubuntu/consul-client/consul.d/certificates/sh_primary-client-consul-0-key.pem","ServerName":"","Verify":false},"Token":"6b2aa087-5752-91e7-82a8-e39dcb0c5946","Transport":{"DialKeepAlive":30000000000,"DialTimeout":30000000000,"DisableKeepAlives":false,"IdleConnTimeout":90000000000,"MaxIdleConns":100,"MaxIdleConnsPerHost":3,"TLSHandshakeTimeout":10000000000}},"Dedup":{"Enabled":false,"MaxStale":2000000000,"Prefix":"consul-template/dedup/","TTL":15000000000},"Exec":{"Command":"chmod +x /home/ubuntu/consul-client/consul-template/scripts/staging/restart-pm2.sh \u0026\u0026 /home/ubuntu/consul-client/consul-template/scripts/staging/restart-pm2.sh","Enabled":true,"Env":{"Blacklist":[],"Custom":[],"Pristine":false,"Whitelist":[]},"KillSignal":2,"KillTimeout":30000000000,"ReloadSignal":null,"Splay":0,"Timeout":0},"KillSignal":2,"LogLevel":"trace","MaxStale":2000000000,"PidFile":"","ReloadSignal":1,"Syslog":{"Enabled":false,"Facility":"LOCAL0"},"Templates":[{"Backup":false,"Command":"","CommandTimeout":30000000000,"Contents":"","CreateDestDirs":true,"Destination":"/home/ubuntu/therm_backend/staging/config/development.json","ErrMissingKey":false,"Exec":{"Command":"","Enabled":false,"Env":{"Blacklist":[],"Custom":[],"Pristine":false,"Whitelist":[]},"KillSignal":2,"KillTimeout":30000000000,"ReloadSignal":null,"Splay":0,"Timeout":30000000000},"Perms":0,"Source":"/home/ubuntu/consul-client/consul-template/config-development.tpl","Wait":{"Enabled":false,"Min":0,"Max":0},"LeftDelim":"","RightDelim":"","FunctionBlacklist":null,"SandboxPath":""}],"Vault":{"Address":"","Enabled":false,"Grace":15000000000,"Namespace":"","RenewToken":true,"Retry":{"Attempts":12,"Backoff":250000000,"MaxBackoff":60000000000,"Enabled":true},"SSL":{"CaCert":"","CaPath":"","Cert":"","Enabled":true,"Key":"","ServerName":"","Verify":true},"Transport":{"DialKeepAlive":30000000000,"DialTimeout":30000000000,"DisableKeepAlives":false,"IdleConnTimeout":90000000000,"MaxIdleConns":100,"MaxIdleConnsPerHost":3,"TLSHandshakeTimeout":10000000000},"UnwrapToken":false},"Wait":{"Enabled":false,"Min":0,"Max":0},"Once":false}
2019/09/16 13:14:08.316912 [WARN] (clients) disabling consul SSL verification
2019/09/16 13:14:08.316956 [INFO] (runner) creating watcher
2019/09/16 13:14:08.317059 [INFO] (runner) starting
2019/09/16 13:14:08.317110 [DEBUG] (runner) running initial templates
2019/09/16 13:14:08.317121 [DEBUG] (runner) initiating run
2019/09/16 13:14:08.317151 [DEBUG] (runner) checking template 46841641fcb88b21762418fccbd183bf
2019/09/16 13:14:08.317519 [DEBUG] (runner) was not watching 1 dependencies
2019/09/16 13:14:08.317629 [DEBUG] (watcher) adding kv.block(therm/development)
2019/09/16 13:14:08.317643 [TRACE] (watcher) kv.block(therm/development) starting
2019/09/16 13:14:08.317660 [DEBUG] (runner) diffing and updating dependencies
2019/09/16 13:14:08.317671 [DEBUG] (runner) watching 1 dependencies
2019/09/16 13:14:08.317709 [TRACE] (view) kv.block(therm/development) starting fetch
2019/09/16 13:14:08.317734 [TRACE] kv.block(therm/development): GET /v1/kv/therm/development?stale=true&wait=1m0s
2019/09/16 13:14:08.322591 [TRACE] kv.block(therm/development): returned "{.......some_values_inside_kv}\n"
2019/09/16 13:14:08.322614 [TRACE] (view) kv.block(therm/development) marking successful data response
2019/09/16 13:14:08.322627 [TRACE] (view) kv.block(therm/development) successful contact, resetting retries
2019/09/16 13:14:08.322644 [TRACE] (view) kv.block(therm/development) received data
2019/09/16 13:14:08.322668 [TRACE] (view) kv.block(therm/development) starting fetch
2019/09/16 13:14:08.322686 [TRACE] kv.block(therm/development): GET /v1/kv/therm/development?index=66707&stale=true&wait=1m0s
2019/09/16 13:14:08.322746 [DEBUG] (runner) receiving dependency kv.block(therm/development)
2019/09/16 13:14:08.322805 [DEBUG] (runner) initiating run
2019/09/16 13:14:08.322823 [DEBUG] (runner) checking template 46841641fcb88b21762418fccbd183bf
2019/09/16 13:14:08.323018 [DEBUG] (runner) rendering "/home/ubuntu/consul-client/consul-template/config-development.tpl" => "/home/ubuntu/therm_backend/staging/config/development.json"
2019/09/16 13:14:08.323077 [DEBUG] (runner) diffing and updating dependencies
2019/09/16 13:14:08.323096 [DEBUG] (runner) kv.block(therm/development) is still needed
2019/09/16 13:14:08.323101 [DEBUG] (runner) watching 1 dependencies
2019/09/16 13:14:08.323106 [DEBUG] (runner) all templates rendered
2019/09/16 13:14:08.323122 [TRACE] (runner) acquired child lock for command, spawning
2019/09/16 13:14:08.323161 [INFO] (child) spawning: chmod +x /home/ubuntu/consul-client/consul-template/scripts/staging/restart-pm2.sh
2019/09/16 13:14:08.324298 [INFO] (runner) child process died
2019/09/16 13:14:08.324320 [DEBUG] (cli) receiving signal "child exited"
2019/09/16 13:14:08.324333 [ERR] (cli) child process died with exit code 0

Expected behavior

I expected to maintain a running process of consul-template

Actual behavior

What actually happened? It returned child process died with exit code 0.

Steps to reproduce

  1. Create a config.development.hcl with it's contents.
  2. create a config file called config-development.tpl with the contents.
  3. Run the command provided.
dibyajyotiron commented 5 years ago

Instead of exec, using command solved the issue. But how to provide CONSUL_TOKEN in the hcl file?