Execute nginx exe in folder with -s reload args Consul template Windows

Home / Uncategorized / Execute nginx exe in folder with -s reload args Consul template Windows

Question:
I am using Consul Template V0.19.0 for windows, for rendering nginx loadbalancing config.It is working as expected.

Now I want the consul template, to execute the nginx exe in a folder with args (-s reload) as below:-

Case 1:template {
source = "Template/template.ctmpl"
destination = "F:\IDE\Visual Studio Collection\Web Servers\nginx-
1.12.0\nginx-1.12.0\conf\nginx.conf"
command = "F:\IDE\Visual Studio Collection\Web Servers\nginx-
1.12.0\nginx-1.12.0\nginx -s reload"
command_timeout = "60s"
}

But it throws error like, "failed to execute command "F:IDEVisual Studio CollectionWeb Serversnginx-1.12.0nginx-1.12.0nginx.exe" from "Template/template.ctmpl" => "F:IDEVisual Studio CollectionWeb Serversnginx-1.12.0nginx-1.12.0confnginx.conf": child: exec: "F:IDEVisual": file does not exist".

Case 2:- Currently I have achieved this by making the nginx as service (using nssm) and gave the command like,
command = "powershell restart-service nginx"

instead of giving the full path followed by "-s reload".

But for this, have to make the nginx as a service using apps like nssm.

May I know, is there any way to tell the command attribute in the consul template config to, "execute the nginx exe in folder like in the Case 1" ?

Thanks.


Answer:
Try this
template {
source = "Template/template.ctmpl"
destination = "F:\IDE\Visual Studio Collection\Web Servers\nginx-
1.12.0\nginx-1.12.0\conf\nginx.conf"
command = ""F:\IDE\Visual Studio Collection\Web Servers\nginx-
1.12.0\nginx-1.12.0\nginx" -s reload"
command_timeout = "60s"
}

If that doesn’t work try below options also for command
command = ""F:/IDE/Visual Studio Collection/Web Servers/nginx-
1.12.0/nginx-1.12.0/nginx" -s reload"

or
command = ""F:\\IDE\\Visual Studio Collection\\Web Servers\\nginx-
1.12.0\\nginx-1.12.0\\nginx" -s reload"
Read more

Leave a Reply

Your email address will not be published. Required fields are marked *