Why service php5-fpm reload for deploy to remote server

Hello folks!

During deploy absible crash with an error message when trying to restart php5-fpm service on my remote server.

TASK: [deploy | Run post_finalize_commands] *********************************** 
    failed: [codeben.ch] => (item=sudo service php5-fpm reload) => {"changed": true, "cmd": "sudo service php5-fpm reload", "delta": "0:00:00.017277", "end": "2015-05-24 14:57:39.931210", "item": "sudo service php5-fpm reload", "rc": 127, "start": "2015-05-24 14:57:39.913933", "warnings": []}
stderr: /bin/sh: sudo: command not found

FATAL: all hosts have already failed -- aborting

My host provider don’t support ‘sudo’ or I can not restart php for my current plan.

Why is it needed to restart the PHP service during a deploy on a remote server?

Greetings!

We reload php5-fpm to guarantee that it and Nginx are pointing to the newest/correct “release path”. Since our deployment system works on symlinks, php-fpm seems to have resolve the symlink and caches the result for a period of time. So we reload php-fpm to force it to resolve the symlink path again to ensure it’s correct.

Example:

before deploy: /srv/www/example.com/current -> /srv/www/example.com/releases/201505221035
next deploy: /srv/www/example.com/current -> /srv/www/example.com/releases/2015052410543

Without the reload php-fpm might still be using code /srv/www/example.com/releases/201505221035 for a short period of time instead of the new one.

If you don’t want it, or want to customize the command, you can just override the project_post_finalize_commands variable

1 Like

Thank you for your quick response.

I use PHP 5.4. How can I find out if symlinks are cached? I found directive about realpath_cache_size and realpath_cache_ttl in the .ini. Is that realpath resolving symlink?

I’d read this + the comments.

1 Like