本文整理汇总了PHP中Main::log_write方法的典型用法代码示例。如果您正苦于以下问题:PHP Main::log_write方法的具体用法?PHP Main::log_write怎么用?PHP Main::log_write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Main
的用法示例。
在下文中一共展示了Main::log_write方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run($task)
{
$cmd = $task["cmd"];
$status = 0;
exec($cmd, $output, $status);
Main::log_write($cmd . ",已执行.status:" . $status);
exit($status);
}
示例2: __construct
public function __construct($file)
{
if (empty($file) || !empty($file) && !file_exists($file)) {
Main::log_write("指定配置文件不存在,file:" . $file);
exit;
}
$this->filePath = $file;
}
示例3: getDbConfig
protected function getDbConfig()
{
$config = (include ROOT_PATH . "config/config.php");
if (empty($config) || !isset($config["mysql"])) {
Main::log_write("mysql config not found");
exit;
}
return $config["mysql"];
}
示例4: autoload
/**
* 子进程 自动载入需要运行的工作类
* @param $class
*/
public function autoload($class)
{
include ROOT_PATH . "plugin" . DS . "PluginBase.class.php";
$file = ROOT_PATH . "plugin" . DS . $class . ".class.php";
if (file_exists($file)) {
include $file;
} else {
Main::log_write("处理类不存在");
}
}
示例5: autoload
/**
* 子进程 自动载入需要运行的工作类
* @param $class
*/
public function autoload($class)
{
include ROOT_PATH . "worker/WorkerBase.class.php";
$file = ROOT_PATH . "worker/" . $class . "Worker" . ".class.php";
if (file_exists($file)) {
include $file;
} else {
Main::log_write("处理类不存在");
}
}
示例6: run
public function run($task)
{
$client = new GearmanClient();
$client->addServers($task["server"]);
$client->doBackground($task["cmd"], $task["ext"]);
if (($code = $client->returnCode()) != GEARMAN_SUCCESS) {
Main::log_write("Gearman:" . $task["cmd"] . " to " . $task["server"] . " error,code=" . $code);
exit;
}
Main::log_write("Gearman:" . $task["cmd"] . " to " . $task["server"] . " success,code=" . $code);
exit;
}
示例7: content
public function content($config)
{
if (!isset($config["host"]) || !isset($config["port"]) || !isset($config["timeout"]) || !isset($config["queue"])) {
Main::log_write(vsprintf(" host=%s,port=%s,timeout=%s,queue=%s", $config));
exit;
}
$this->Redis = new Redis();
if (!$this->Redis->pconnect($config["host"], $config["port"], isset($config["timeout"]))) {
Main::log_write(vsprintf("redis can't connect.host=%s,port=%s,timeout=%s", $config));
exit;
}
if (isset($config["db"]) && is_numeric($config["db"])) {
$this->Redis->select($config["db"]);
}
$this->queue = $config["queue"];
}
示例8: params_s
/**
* 解析启动模式参数
* @param $opt
*/
public static function params_s($opt)
{
//判断传入了s参数但是值,则提示错误
if (isset($opt["s"]) && !$opt["s"] || isset($opt["s"]) && !in_array($opt["s"], array("start", "stop", "restart"))) {
Main::log_write("Please run: path/to/php main.php -s [start|stop|restart]");
}
if (isset($opt["s"]) && in_array($opt["s"], array("start", "stop", "restart"))) {
switch ($opt["s"]) {
case "start":
Crontab::start();
break;
case "stop":
Crontab::stop();
break;
case "restart":
Crontab::restart();
break;
}
}
}
示例9: register_signal
/**
* 注册信号
*/
private static function register_signal()
{
swoole_process::signal(SIGTERM, function ($signo) {
self::exit2p("收到退出信号,退出主进程");
});
swoole_process::signal(SIGCHLD, function ($signo) {
while ($ret = swoole_process::wait(false)) {
$pid = $ret['pid'];
if (isset(self::$task_list[$pid])) {
$task = self::$task_list[$pid];
if ($task["type"] == "crontab") {
$end = microtime(true);
$start = $task["start"];
$id = $task["id"];
Main::log_write("{$id} [Runtime:" . sprintf("%0.6f", $end - $start) . "]");
$task["process"]->close();
//关闭进程
unset(self::$task_list[$pid]);
if (isset(self::$unique_list[$id]) && self::$unique_list[$id] > 0) {
self::$unique_list[$id]--;
}
}
if ($task["type"] == "worker") {
$end = microtime(true);
$start = $task["start"];
$classname = $task["classname"];
Main::log_write("{$classname}_{$task["number"]} [Runtime:" . sprintf("%0.6f", $end - $start) . "]");
$task["process"]->close();
//关闭进程
(new Worker())->create_process($classname, $task["number"], $task["redis"]);
}
}
}
});
swoole_process::signal(SIGUSR1, function ($signo) {
//TODO something
});
}
示例10: register_signal
/**
* 注册信号
*/
private static function register_signal()
{
swoole_process::signal(SIGTERM, function ($signo) {
if (!empty(Main::$http_server)) {
swoole_process::kill(Main::$http_server->pid, SIGKILL);
}
self::exit2p("收到退出信号,退出主进程");
});
swoole_process::signal(SIGCHLD, function ($signo) {
while (($pid = pcntl_wait($status, WNOHANG)) > 0) {
$task = self::$task_list[$pid];
$end = microtime(true);
$start = $task["start"];
$id = $task["id"];
Main::log_write("{$id} [Runtime:" . sprintf("%0.6f", $end - $start) . "]");
unset(self::$task_list[$pid]);
if (isset(self::$unique_list[$id]) && self::$unique_list[$id] > 0) {
self::$unique_list[$id]--;
}
}
});
swoole_process::signal(SIGUSR1, function ($signo) {
LoadConfig::reload_config();
});
}
示例11: http_run
/**
* 运行httpserver
* @param $worker
*/
public function http_run($worker)
{
Main::log_write("HTTP Server 已启动");
$binpath = $_SERVER["_"];
$worker->exec($binpath, array(ROOT_PATH . "/http.php", $worker->pipe, Crontab::$config_file, self::$host, self::$port));
}
示例12: exit2p
/**
* 退出主进程
* @param $msg
*/
public static function exit2p($msg)
{
@unlink(self::$pid_file);
Main::log_write($msg . "\n");
exit;
}