function _gree_fastprocessor_daemon($ident, $concurrency, $max_request)
{
    posix_setsid();
    // check pid
    $r = _gree_fastprocessor_check_pid("gree_fastprocessor.{$ident}", getmypid(), GREE_FASTPROCESSOR_PID_DIR);
    if ($r == false) {
        print "another gree_fastprocessor has been already started...exiting\n";
        return $r;
    }
    // save option (for restarting)
    $option_file = sprintf("%s/_gree_fastprocessor.%s.option", GREE_FASTPROCESSOR_PID_DIR, $ident);
    $fp = fopen($option_file, "w");
    fwrite($fp, serialize(array('ident' => $ident, 'concurrency' => $concurrency, 'max-request' => $max_request)));
    fclose($fp);
    $gfp = new Gree_FastProcessor();
    $gfp->listen($ident, $concurrency, $max_request);
    // skip clearing pid file here (_gree_async_kill() will do this)
    return 0;
}
#!/usr/local/bin/php
<?php 
require_once 'gree_fastprocessor.php';
$gfp = new Gree_FastProcessor();
$gfp->initialize();
// pre-requires (anything you need)
// from app/webroot/index.php
if (!defined('DS')) {
    define('DS', DIRECTORY_SEPARATOR);
}
if (!defined('ROOT')) {
    define('ROOT', '/home/cake');
}
if (!defined('APP_DIR')) {
    define('APP_DIR', 'app');
}
if (!defined('CAKE_CORE_INCLUDE_PATH')) {
    define('CAKE_CORE_INCLUDE_PATH', ROOT);
}
if (!defined('WEBROOT_DIR')) {
    define('WEBROOT_DIR', 'webroot');
}
if (!defined('WWW_ROOT')) {
    define('WWW_ROOT', ROOT . DS . APP_DIR . DS . WEBROOT_DIR . DS);
}
if (!defined('CORE_PATH')) {
    if (function_exists('ini_set')) {
        ini_set('include_path', CAKE_CORE_INCLUDE_PATH . PATH_SEPARATOR . ROOT . DS . APP_DIR . DS . PATH_SEPARATOR . ini_get('include_path'));
        define('APP_PATH', null);
        define('CORE_PATH', null);
    } else {