Hacker News new | ask | show | jobs
by danenania 3019 days ago
Good to know - as you can see, I don't have a lot of PHP experience.

If anyone knows of a good way to get a PHP process's parent server pid (regardless of what server it's running on), please let me know :)

1 comments

PHP has an execution model that's /really/ bad for per-process requests. Even attempting to grab the parent pid is probably not sufficient as you can have execution contexts with no parent (ex: running php from cron).

On linux you can get the master process through posix-getppid (http://php.net/manual/en/function.posix-getppid.php) but this won't work on windows and has the same limitations as above.

Have you thought about having a linux daemon/agent that runs in the background and keeps the ENV in sync?

I think a caching daemon would be good option for PHP, but it does add a level of complexity.

Another option would be to add EnvKey support to confd (or similar project), and provide config and template files that write the env vars to Apache and Nginx configs, and reload when they change.

Though neither confd or a daemon would work for PHP sites that use a PaaS or shared hosting, which I think is a large percentage of the market for PHP.

Using one of the existing PHP caching solutions (like opcache) might be an option.

> Have you thought about having a linux daemon/agent that runs in the background and keeps the ENV in sync?

Yes, though I think it's also important to give developers control of when their config reloads, since surprises here can be dangerous.

I think having a daemon running on the OS that only syncs with an explicit ‘service envkey reload’ would work well.

If running php with nginx (via php-fpm), it’s still common for worker processes to come and go rather frequently. Imo, per-request pricing just won’t work well with php.

I would love to use your product, btw. Congratulations on launch.

-php dev