bripkens / proxrox

Proxy services, combine origins, use SSI and more during development

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

proxrox stop might kill unrelated instances of nginx

basti1302 opened this issue · comments

As discussed in #14

@basti1302:

On a slightly related note, it feels a little bit brute-force-y to just kill all nginx master processes. It might be quite unlikely, but there could be another, completely unrelated, nginx process around, right?

What about spawning the nginx process via node core's child_process.spawn on proxrox start, remembering the pid (in the tmp folder), and killing only the process with that pid on proxrox stop?

@bripkens:

I very much like the idea! But then proxrox stop could only stop the last started nginx process. Can we come up with a strategy to stop the nginx process which is currently running for a given .proxrox.yaml file?

I investigated a bit yesterday. The pid returned by child_process.spawnSync is not the pid of the nginx master process. Apparently nginx -c ... -p ... (the command used to start nginx) starts a short lived process which in turn spawns the master process. However, the nginx pid is already available in /tmp/proxrox/uuid/log/nginx.pid because this is configured in the nginx config template.

So we could have a look at all existing files that match the pattern /tmp/proxrox/uuid/log/nginx.pid, read the pids from those files and kill only those processes. That still would kill all nginx processes created by proxrox but it is a bit better than killing all nginx intances, even those not created by proxrox.

The alternative would be to put a file (only the pid or the whole tmp structure) into the current directory but that creates some new problems.

I think there is no third alternative, as proxrox has no persistent storage between proxrox start and proxrox stop.