nginx pid directive and reload doesnot work in openresty

1,139 views
Skip to first unread message

项楠

unread,
May 24, 2016, 11:27:41 PM5/24/16
to openresty-en

user  root;
pid   /tmp/nginx.pid;
worker_processes  1;
error_log  logs/error.log  error;

events {
    worker_connections  1024;
}


http {
    default_type  "text/html; charset=UTF-8";
    server {
        listen       8080;
        server_name  localhost;
        location / {
            root   html;
        }
    }

}



I install openresty in the default path. my project path is `/root/op`, and I start with 
nginx -p `pwd`/ -c conf/nginx.conf


But 
1. openresty still create pid file in `/root/op/logs/`
2. when you try `nginx -s reload`, it fails with 
nginx: [error] open() "/usr/local/openresty/nginx/logs/nginx.pid" failed (2: No such file or directory)



so question is:
1.how to specify location of pid file?
2.how to reload nginx?

Yichun Zhang (agentzh)

unread,
May 27, 2016, 4:16:55 PM5/27/16
to openresty-en
Hello!

On Tue, May 24, 2016 at 8:27 PM, 项楠 wrote:
> I install openresty in the default path. my project path is `/root/op`, and
> I start with
> nginx -p `pwd`/ -c conf/nginx.conf
>
>
> But
> 1. openresty still create pid file in `/root/op/logs/`
> 2. when you try `nginx -s reload`, it fails with
> nginx: [error] open() "/usr/local/openresty/nginx/logs/nginx.pid" failed (2:
> No such file or directory)
>

Because you started your nginx with the -p option, then you should
still use that exactly the same -p option when calling nginx with
-sreload.

BTW, do not use nginx -sreload to reload nginx unless you are on
Windows. Always send the HUP signal to your nginx master process
directly. The -s option has unwanted side-effects that may surprise
you (like loading the nginx configuration one more time).

Regards,
-agentzh
Reply all
Reply to author
Forward
0 new messages