Nginx issues about Habitat CLI for Windows


Hi there! I want to ask you all some questions about how to run nginx application with Habitat CLI for Windows.
I just don’t know how to write the plan.sh1 file and run file. If the files look like this,is that right? Also,there is my nginx.conf. And I want to know how to start hab services up, is the “hab svc load/start”? Before this,should i install the core/windows-service? Plzzzzzzz help me!!!




Sorry for taking so long to respond. We don’t have any example windows based nginx plans but looking over what you have, your plan.ps1 looks ok. It looks very "bash"ish but should run in powershell. You could completely remove the Invoke-Build since it just returns 0.

The run hook would look something like:

nginx -c {{pkg.path }}\dist\config\nginx.conf

No need for pkgPathFor since nginx's bin dir will be on the path.


I just changed the run file like you said but it didn’t work.This is the nginx.conf and after building I try to use ‘hab load/start svc xlk-test1/hello-test1’ to open my website,but it failed.I also try to install ‘core/windows-service by using’, after ‘hab sup run’ it shows wrong logs.nginx start


I think there may be a few things going on here:

  1. your plan specifies a svc_user named root. That assumes that there is a user named root on the machine which looks like it is missing. For Windows plans, most don’t use the svc_user which causes the service to run under the same account as the supervisor. I would start with removing that from your plan.

  2. If you want to run the supervisor inside of a Windows Service which is the way to go in a production environment, then the service calls hab sup run and you control the supervisor by starting and stopping the service. Not sure exactly what is meant by shows wrong logs but I’s start by not using the windows-service and just getting things working in the studio.

  3. I think I was incorrect in my nginx call above that points to {{pkg.path }}\dist\config\nginx.conf. It should point to {{pkg.path }}\config\nginx.conf instead.


I noticed that your third point,so I used ‘{{pkg.path }}\config\nginx.conf’ last time.

Now I delete the ‘svc_user=root’ in plan.sh1 and this time there are no wrong logs but still can’t open the website.

Then I try ‘hab sup run’, it shows wrong logs, so I just kill the process which pid=7260, and I try ‘hab sup run’ again and open another cmd.exe to ‘hab svc load/start’. It shows wrongs logs.(the bule part is my Windows administrator identity name)


The error with the pipe removal is actually just noise. We have an open issue to address that but it should not be affecting you here. It looks like your real problems are with the error.log file and the pid directive. You probably need to create the logs directory in an init hook. Based on your config above it seems like you are terminating pid with a ; but you can look at /hab/svc/hello-test1/config/nginx.conf to see how the template got rendered and ensure it looks right.

Also, hab sup run usually will not work in a studio because the studio starts with a running supervisor. After loading your service (and there should be no need to call hab svc start afterwards) you can run Get-SupervisorLog to view the Supervisor output.