示例#1
0
/**
 * log_message : log message
 * @param  string $level   log level
 * @param  string $message message
 * @return None
 */
function log_message($level, $message = '')
{
    $level = strtoupper($level);
    $begin = '';
    $end = '';
    $log = AppServer::get_instance()->get_log_file();
    if (empty($log)) {
        switch ($level) {
            case 'ERROR':
                $begin = "";
                $end = "";
                break;
            case 'INFO':
                $begin = "";
                $end = "";
                break;
            default:
                break;
        }
    }
    $output = $begin . date('m-d H:i:s') . ' @' . getmypid() . ' : [' . $level . '] ' . $message . $end . PHP_EOL;
    if (empty($log)) {
        fwrite(STDERR, $output);
    } else {
        $lock = new swoole_lock(SWOOLE_MUTEX);
        $lock->lock();
        $fp = fopen($log, 'a+');
        fwrite($fp, $output);
        fclose($fp);
        $lock->unlock();
    }
}
示例#2
0
文件: client.php 项目: robinmin/swale
 * This can be set to anything, but default usage is:
 *
 *     development
 *     testing
 *     production
 *
 * NOTE: If you change these, also change the error_reporting() code below
 *
 */
define('SYS_ENV', 'development');
/**
 * SYS_PATH : Path name of the system
 */
if (file_exists(__DIR__ . '/sys')) {
    define('SYS_PATH', __DIR__ . '/sys');
} else {
    define('SYS_PATH', __DIR__ . '/vendor/robinmin/swale/sys');
}
/**
 * APP_PATH : Path name of the current application
 */
define('APP_PATH', __DIR__ . '/apps');
/**
 * Load necessary class definition to start the server
 */
require SYS_PATH . '/core/bootstrap.php';
/**
 * Start the Application server
 */
AppServer::get_instance([])->request($argv);
示例#3
0
文件: server.php 项目: robinmin/swale
 * This can be set to anything, but default usage is:
 *
 *     development
 *     testing
 *     production
 *
 * NOTE: If you change these, also change the error_reporting() code below
 *
 */
define('SYS_ENV', 'development');
/**
 * SYS_PATH : Path name of the system
 */
if (file_exists(__DIR__ . '/sys')) {
    define('SYS_PATH', __DIR__ . '/sys');
} else {
    define('SYS_PATH', __DIR__ . '/vendor/robinmin/swale/sys');
}
/**
 * APP_PATH : Path name of the current application
 */
define('APP_PATH', __DIR__ . '/apps');
/**
 * Load necessary class definition to start the server
 */
require SYS_PATH . '/core/bootstrap.php';
/**
 * Start the Application server
 */
AppServer::get_instance([])->start();
示例#4
0
 public function test_session()
 {
     $app = super_app::get_app();
     $new_val = rand(1, 9999);
     $app->session->set('once', $new_val);
     $domain = AppServer::get_instance()->config->get('session_domain', __METHOD__);
     $test = $app->session->get('once');
     $this->_assert_true($new_val === $test && $new_val === $_SESSION[$domain]['once'], 'Run task');
 }
示例#5
0
文件: mvc.php 项目: robinmin/swale
 /**
  * __get : get plugin by name for current working process
  * @param  string  $plugin  plugin name
  * @return mixed       plugin instance or false if none can be found
  */
 public function __get($plugin)
 {
     // if can find the plugin in sys_plugin list
     $plgn = AppServer::get_instance()->get_plugin($plugin);
     if ($plgn === false) {
         // if can find the plugin in http_plugin list
         return parent::__get($plugin);
     }
     return $plgn;
 }
示例#6
0
文件: plugin.php 项目: robinmin/swale
 /**
  * init : init function
  * @return boolean    operation result
  */
 public function init()
 {
     $svr = AppServer::get_instance();
     $option = isset($svr->config['cache']) ? $svr->config['cache'] : array();
     $ssdb = new SSDB\Client(isset($option['ip']) ? $option['ip'] : '127.0.0.1', isset($option['port']) ? $option['port'] : 8888);
     $handler = new SSDBSession\SessionHandler($ssdb);
     session_set_save_handler($handler, true);
     session_start();
 }