sforkowany z mirror/friendica
				
			The daemon now works fine
							rodzic
							
								
									369fcb7bae
								
							
						
					
					
						commit
						611c38b3e3
					
				|  | @ -1,6 +1,7 @@ | ||||||
|  | #!/usr/bin/env php
 | ||||||
| <?php | <?php | ||||||
| /** | /** | ||||||
|  * @file util/daemon.php |  * @file scripts/daemon.php | ||||||
|  * @brief Run the worker from a daemon. |  * @brief Run the worker from a daemon. | ||||||
|  * |  * | ||||||
|  * This script was taken from http://php.net/manual/en/function.pcntl-fork.php |  * This script was taken from http://php.net/manual/en/function.pcntl-fork.php | ||||||
|  | @ -25,7 +26,19 @@ if (!isset($mode)) { | ||||||
| 	die("Please use either 'start', 'stop' or 'status'.\n"); | 	die("Please use either 'start', 'stop' or 'status'.\n"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @include(".htconfig.php"); | if (empty($_SERVER["argv"][0])) { | ||||||
|  | 	die("Unexpected script behaviour. This message should never occur.\n"); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // Fetch the base directory
 | ||||||
|  | $directory = dirname($_SERVER["argv"][0]); | ||||||
|  | 
 | ||||||
|  | if (substr($directory, 0, 1) != "/") { | ||||||
|  | 	$directory = $_SERVER["PWD"]."/".$directory; | ||||||
|  | } | ||||||
|  | $directory = realpath($directory."/.."); | ||||||
|  | 
 | ||||||
|  | @include($directory."/.htconfig.php"); | ||||||
| 
 | 
 | ||||||
| if (!isset($pidfile)) { | if (!isset($pidfile)) { | ||||||
| 	die('Please specify a pid file in the variable $pidfile in the .htconfig.php. For example:'."\n". | 	die('Please specify a pid file in the variable $pidfile in the .htconfig.php. For example:'."\n". | ||||||
|  | @ -93,7 +106,20 @@ while (true) { | ||||||
| 	// Call the worker
 | 	// Call the worker
 | ||||||
| 	$cmdline = $php.' scripts/worker.php'; | 	$cmdline = $php.' scripts/worker.php'; | ||||||
| 
 | 
 | ||||||
| 	exec($cmdline); | 	$executed = false; | ||||||
|  | 
 | ||||||
|  | 	if (function_exists('proc_open')) { | ||||||
|  | 		$resource = proc_open($cmdline . ' &', array(), $foo, $directory); | ||||||
|  | 
 | ||||||
|  | 		if (is_resource($resource)) { | ||||||
|  | 			$executed = true; | ||||||
|  | 			proc_close($resource); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	if (!$executed) { | ||||||
|  | 		exec($cmdline.' spawn'); | ||||||
|  | 	} | ||||||
| 
 | 
 | ||||||
| 	// Now sleep for 5 minutes
 | 	// Now sleep for 5 minutes
 | ||||||
| 	sleep(300); | 	sleep(300); | ||||||
|  |  | ||||||
|  | @ -1,3 +1,4 @@ | ||||||
|  | #!/usr/bin/env php
 | ||||||
| <?php | <?php | ||||||
| /** | /** | ||||||
|  * @file scripts/dbstructure.php |  * @file scripts/dbstructure.php | ||||||
|  |  | ||||||
|  | @ -1,4 +1,10 @@ | ||||||
|  | #!/usr/bin/env php
 | ||||||
| <?php | <?php | ||||||
|  | /** | ||||||
|  |  * @file scripts/worker.php | ||||||
|  |  * @brief Starts the background processing | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
| use Friendica\App; | use Friendica\App; | ||||||
| use Friendica\Core\Worker; | use Friendica\Core\Worker; | ||||||
| use Friendica\Core\Config; | use Friendica\Core\Config; | ||||||
|  | @ -38,7 +44,15 @@ $a->set_baseurl(Config::get('system', 'url')); | ||||||
| 
 | 
 | ||||||
| load_hooks(); | load_hooks(); | ||||||
| 
 | 
 | ||||||
|  | $spawn = (($_SERVER["argc"] <= 1) || ($_SERVER["argv"][1] == "spawn")); | ||||||
|  | 
 | ||||||
|  | if ($spawn) { | ||||||
|  | 	Worker::spawnWorker(); | ||||||
|  | 	killme(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| $run_cron = (($_SERVER["argc"] <= 1) || ($_SERVER["argv"][1] != "no_cron")); | $run_cron = (($_SERVER["argc"] <= 1) || ($_SERVER["argv"][1] != "no_cron")); | ||||||
|  | 
 | ||||||
| Worker::processQueue($run_cron); | Worker::processQueue($run_cron); | ||||||
| 
 | 
 | ||||||
| Worker::unclaimProcess(); | Worker::unclaimProcess(); | ||||||
|  |  | ||||||
		Ładowanie…
	
		Reference in New Issue
	
	 Michael
						Michael