Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execute PHP script after php-fpm master process is restarted

Say I have a script to populate the PHP APC cache when PHP is restarted, the cache is empty.

Is it possible to create a mechanism to autorun some kind of script when the master php-fpm process is started?

like image 520
Ryan Avatar asked May 31 '19 04:05

Ryan


2 Answers

Open php-fpm

vim /etc/init.d/php-fpm

In the file, find the start function, add your commands at the end.

start () {
    ...
    # Your commands here
}

Save and restart php-fpm

like image 91
shingo Avatar answered Sep 26 '22 03:09

shingo


I have one article for you please once read it, It might be helpful to you Link

Open php-frm through CMD

Ubantu sudo gedit /etc/init.d/php-fpm

You put the code under following function.

function start {
   /* 
     Your code here
   */
}
like image 38
Dhruv Avatar answered Sep 26 '22 03:09

Dhruv