Consul Template V0.19.0を使用しています 窓用、nginxの負荷分散設定をレンダリングするため。期待どおりに動作しています。
今、私はconsulテンプレートが欲しいです、下のようにargs(-s reload)でフォルダ内のnginx exeを実行します:
ケース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"
}
しかし、「実行に失敗しました」のようなエラーがスローされますコマンド "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":子: exec: "F:IDEVisual":ファイルが存在しません "。
ケース2:- 現在、nsinmをサービスとしてnginxを作成することでこれを達成し、次のようなコマンドを与えました。
command = "powershell restart-service nginx"
「-s reload」に続くフルパスを指定する代わりに。
ただし、このためには、nssmなどのアプリを使用してnginxをサービスとして作成する必要があります。
私が知っているかもしれませんが、consulテンプレート設定のコマンド属性に、「フォルダ内のnginx exeを ケース1"?
ありがとう。
回答:
回答№1は0これを試して
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"
}
うまくいかない場合は、以下のコマンドのオプションも試してください
command = ""F:/IDE/Visual Studio Collection/Web Servers/nginx-
1.12.0/nginx-1.12.0/nginx" -s reload"
または
command = ""F:\\IDE\\Visual Studio Collection\\Web Servers\\nginx-
1.12.0\\nginx-1.12.0\\nginx" -s reload"
編集-1
議論に基づいて、それはあなたのようですnginx configには、相対フォルダーベースの構成があります。 nginxをフォルダーから起動した場合、同じフォルダーから再読み込みする必要もあります。そのため、フォルダに変更してから、reloadコマンドを実行する必要があります。あなたが試すべき2つの形式は
command="cd "<NGINX FOLDER PATH>" && nginx -s reload"
または
command="cmd /k "cd "<NGINX FOLDER PATH>" && nginx -s reload""