init
This commit is contained in:
@@ -19,6 +19,10 @@ class Config
|
||||
get => $this->errorLogRotationTimeByDay;
|
||||
}
|
||||
|
||||
public bool $consoleLog {
|
||||
get => $this->consoleLog;
|
||||
}
|
||||
|
||||
public DatabaseConfig $database {
|
||||
get => $this->database;
|
||||
}
|
||||
@@ -52,14 +56,14 @@ class Config
|
||||
/**
|
||||
* TCP Server 进程数量
|
||||
*/
|
||||
public int $tcpServerProcessNum = 1 {
|
||||
public int $tcpServerProcessNum {
|
||||
get => $this->tcpServerProcessNum;
|
||||
}
|
||||
|
||||
/**
|
||||
* TCP_SERVER_PORT
|
||||
*/
|
||||
public int $tcpServerPort = 50000 {
|
||||
public int $tcpServerPort {
|
||||
get => $this->tcpServerPort;
|
||||
}
|
||||
|
||||
@@ -97,6 +101,7 @@ class Config
|
||||
$this->database = new DatabaseConfig();
|
||||
$this->dbDebug = self::getBoolEnv('DB_DEBUG');
|
||||
$this->logFilter = self::getStringArrayEnv('LOG_FILTER', []);
|
||||
$this->consoleLog = self::getBoolEnv('CONSOLE_LOG', false);
|
||||
$this->logLevel = match (strtoupper(self::getStringEnv('LOG_LEVEL', 'DEBUG'))) {
|
||||
'INFO' => \Monolog\Logger::INFO,
|
||||
'WARNING' => \Monolog\Logger::WARNING,
|
||||
@@ -116,6 +121,7 @@ class Config
|
||||
$this->zlm = new ZLMConfig();
|
||||
$this->personDetectionCallback = null;
|
||||
$this->enableRequestTimeLog = self::getBoolEnv('ENABLE_REQUEST_TIME_LOG', false);
|
||||
$this->tcpServerProcessNum = self::getIntEnv('TCP_SERVER_PROCESS_NUM', 1);
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' && $this->tcpServerProcessNum > 1) {
|
||||
$this->tcpServerProcessNum = 1;
|
||||
echo "Warning: TCP_SERVER_PROCESS_NUM set to 1 on Windows.\n";
|
||||
|
||||
@@ -9,32 +9,64 @@ use support\Db;
|
||||
class DatabaseConfig
|
||||
{
|
||||
public string $host = 'localhost' {
|
||||
get {
|
||||
return $this->host;
|
||||
}
|
||||
get => $this->host;
|
||||
}
|
||||
public string $username = 'root' {
|
||||
get {
|
||||
return $this->username;
|
||||
}
|
||||
get => $this->username;
|
||||
}
|
||||
public string $password = '' {
|
||||
get {
|
||||
return $this->password;
|
||||
}
|
||||
get => $this->password;
|
||||
}
|
||||
public string $database = 'opm_ectms' {
|
||||
get {
|
||||
return $this->database;
|
||||
}
|
||||
public string $database = 'ds2' {
|
||||
get => $this->database;
|
||||
}
|
||||
public int $port = 3306{
|
||||
get => $this->port;
|
||||
}
|
||||
|
||||
public string $charset = 'utf8mb4'{
|
||||
get => $this->charset;
|
||||
}
|
||||
//collation
|
||||
public string $collation = 'utf8mb4_general_ci'{
|
||||
get => $this->collation;
|
||||
}
|
||||
//driver
|
||||
public string $driver = 'mysql'{
|
||||
get => $this->driver;
|
||||
}
|
||||
|
||||
public int $max_connections = 5{
|
||||
get => $this->max_connections;
|
||||
}
|
||||
public int $min_connections = 1{
|
||||
get => $this->min_connections;
|
||||
}
|
||||
public int $wait_timeout = 3{
|
||||
get => $this->wait_timeout;
|
||||
}
|
||||
public int $idle_timeout = 60{
|
||||
get => $this->idle_timeout;
|
||||
}
|
||||
public int $heartbeat_interval = 50{
|
||||
get => $this->heartbeat_interval;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->host = getenv('DB_HOST');
|
||||
$this->username = getenv('DB_USER');
|
||||
$this->password = getenv('DB_PASSWORD');
|
||||
$this->database = getenv('DB_NAME');
|
||||
$this->host = getenv('DB_HOST', $this->host);
|
||||
$this->username = getenv('DB_USER', $this->username);
|
||||
$this->password = getenv('DB_PASSWORD', $this->password);
|
||||
$this->database = getenv('DB_NAME', $this->database);
|
||||
$this->port = getenv('DB_PORT', $this->port);
|
||||
$this->charset = getenv('DB_CHARSET', $this->charset);
|
||||
$this->collation = getenv('DB_COLLATION', $this->collation);
|
||||
$this->driver = getenv('DB_DRIVER', $this->driver);
|
||||
$this->max_connections = getenv('DB_MAX_CONNECTIONS', $this->max_connections);
|
||||
$this->min_connections = getenv('DB_MIN_CONNECTIONS', $this->min_connections);
|
||||
$this->wait_timeout = getenv('DB_WAIT_TIMEOUT', $this->wait_timeout);
|
||||
$this->idle_timeout = getenv('DB_IDLE_TIMEOUT', $this->idle_timeout);
|
||||
$this->heartbeat_interval = getenv('DB_HEARTBEAT_INTERVAL', $this->heartbeat_interval);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user