How can I ensure I have only one instance of a PHP script running via Apache?

前端 未结 3 1628
暗喜
暗喜 2020-12-14 04:40

I have an index.php script that I use as a post-commit URL on a Google Code site. This script clones a directory and builds a project that may take some work.

3条回答
  •  盖世英雄少女心
    2020-12-14 05:03

    how long does it take to run.

    could use memcache

    get( 'job_running' ) ) exit;
    
    else $m->set( 'job_running', true );
    
    
    
    //index code here
    
    //at the end of the script
    
    $m->delete( 'job_running' );
    
    ?>
    

    If the task fails you will need to clear from memcache. Flock is a good option too... probably better actually.

提交回复
热议问题