mirror of
https://github.com/danog/TelegramApiServer.git
synced 2024-11-26 11:54:42 +01:00
Support all db providers from madeline
This commit is contained in:
parent
296df55a29
commit
3be5e22927
@ -39,12 +39,12 @@ TELEGRAM_PROXY_PASSWORD=
|
||||
# Change this type to convert session:
|
||||
DB_TYPE=mysql
|
||||
# MYSQL Settings. Required, when DB_TYPE=mysql
|
||||
MYSQL_HOST=mysql
|
||||
MYSQL_PORT=3306
|
||||
MYSQL_USER=root
|
||||
MYSQL_PASSWORD=
|
||||
MYSQL_DATABASE=MadelineProto
|
||||
MYSQL_MAX_CONNECTIONS=10
|
||||
MYSQL_IDLE_TIMEOUT=60
|
||||
DB_HOST=mysql
|
||||
DB_PORT=3306
|
||||
DB_USER=root
|
||||
DB_PASSWORD=
|
||||
DB_DATABASE=MadelineProto
|
||||
DB_MAX_CONNECTIONS=10
|
||||
DB_IDLE_TIMEOUT=60
|
||||
# Recent data will be stored in memory this amount of time:
|
||||
MYSQL_CACHE_TTL="+5 minutes"
|
||||
DB_CACHE_TTL="+5 minutes"
|
16
.env.example
16
.env.example
@ -39,12 +39,12 @@ TELEGRAM_PROXY_PASSWORD=
|
||||
# Change this type to convert session:
|
||||
DB_TYPE=memory
|
||||
# MYSQL Settings. Required, when DB_TYPE=mysql
|
||||
MYSQL_HOST=127.0.0.1
|
||||
MYSQL_PORT=3306
|
||||
MYSQL_USER=root
|
||||
MYSQL_PASSWORD=
|
||||
MYSQL_DATABASE=MadelineProto
|
||||
MYSQL_MAX_CONNECTIONS=10
|
||||
MYSQL_IDLE_TIMEOUT=60
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
DB_USER=root
|
||||
DB_PASSWORD=
|
||||
DB_DATABASE=MadelineProto
|
||||
DB_MAX_CONNECTIONS=10
|
||||
DB_IDLE_TIMEOUT=60
|
||||
# Recent data will be stored in memory this amount of time:
|
||||
MYSQL_CACHE_TTL="+5 minutes"
|
||||
DB_CACHE_TTL="+5 minutes"
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use TelegramApiServer\Logger;
|
||||
use TelegramApiServer\Migrations\EnvUpgrade;
|
||||
|
||||
$root = __DIR__;
|
||||
const ENV_VERSION='1';
|
||||
@ -23,6 +24,8 @@ const ENV_VERSION='1';
|
||||
//Config init
|
||||
{
|
||||
if (!getenv('SERVER_ADDRESS')) {
|
||||
EnvUpgrade::mysqlToDbPrefix();
|
||||
|
||||
$envFile = $options['env'];
|
||||
if (empty($envFile)) {
|
||||
throw new InvalidArgumentException('Env file not defined');
|
||||
|
@ -14,7 +14,7 @@
|
||||
"amphp/websocket-server": "dev-master",
|
||||
"amphp/websocket-client": "dev-master",
|
||||
"vlucas/phpdotenv": "^4",
|
||||
"danog/madelineproto":"dev-banned_session_handler_fix",
|
||||
"danog/madelineproto":"dev-master",
|
||||
"danog/tgseclib": "^3",
|
||||
"amphp/http-server-form-parser": "^1.1"
|
||||
},
|
||||
|
12
composer.lock
generated
12
composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "b970e8526530b3a7dbf8444415275d9f",
|
||||
"content-hash": "5c7f2c233c20d70ced8e832eb6f64623",
|
||||
"packages": [
|
||||
{
|
||||
"name": "amphp/amp",
|
||||
@ -2134,16 +2134,16 @@
|
||||
},
|
||||
{
|
||||
"name": "danog/madelineproto",
|
||||
"version": "dev-banned_session_handler_fix",
|
||||
"version": "dev-master",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/danog/MadelineProto.git",
|
||||
"reference": "d5b5dc49e89a59ea153ad28fbdc5579bc7e9ae0c"
|
||||
"reference": "463e807dbec457bf61ac99dd47800cd97d5e71b6"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/danog/MadelineProto/zipball/d5b5dc49e89a59ea153ad28fbdc5579bc7e9ae0c",
|
||||
"reference": "d5b5dc49e89a59ea153ad28fbdc5579bc7e9ae0c",
|
||||
"url": "https://api.github.com/repos/danog/MadelineProto/zipball/463e807dbec457bf61ac99dd47800cd97d5e71b6",
|
||||
"reference": "463e807dbec457bf61ac99dd47800cd97d5e71b6",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -2249,7 +2249,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2020-10-02T23:20:06+00:00"
|
||||
"time": "2020-10-02T23:49:46+00:00"
|
||||
},
|
||||
{
|
||||
"name": "danog/magicalserializer",
|
||||
|
18
config.php
18
config.php
@ -37,15 +37,15 @@ $settings = [
|
||||
],
|
||||
'db' => [
|
||||
'type' => getenv('DB_TYPE'),
|
||||
'mysql' => [
|
||||
'host' => getenv('MYSQL_HOST'),
|
||||
'port' => (int) getenv('MYSQL_PORT'),
|
||||
'user' => getenv('MYSQL_USER'),
|
||||
'password' => getenv('MYSQL_PASSWORD'),
|
||||
'database' => getenv('MYSQL_DATABASE'),
|
||||
'max_connections' => (int) getenv('MYSQL_MAX_CONNECTIONS'),
|
||||
'idle_timeout' => (int) getenv('MYSQL_IDLE_TIMEOUT'),
|
||||
'cache_ttl' => getenv('MYSQL_CACHE_TTL'),
|
||||
getenv('DB_TYPE') => [
|
||||
'host' => getenv('DB_HOST'),
|
||||
'port' => (int) getenv('DB_PORT'),
|
||||
'user' => getenv('DB_USER'),
|
||||
'password' => getenv('DB_PASSWORD'),
|
||||
'database' => getenv('DB_DATABASE'),
|
||||
'max_connections' => (int) getenv('DB_MAX_CONNECTIONS'),
|
||||
'idle_timeout' => (int) getenv('DB_IDLE_TIMEOUT'),
|
||||
'cache_ttl' => getenv('DB_CACHE_TTL'),
|
||||
]
|
||||
],
|
||||
'download'=>[
|
||||
|
16
src/Migrations/EnvUpgrade.php
Normal file
16
src/Migrations/EnvUpgrade.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace TelegramApiServer\Migrations;
|
||||
|
||||
class EnvUpgrade
|
||||
{
|
||||
public static function mysqlToDbPrefix() {
|
||||
foreach (glob(ROOT_DIR . '/.env*') as $envFile) {
|
||||
$text = file_get_contents($envFile);
|
||||
$text = preg_replace('/^MYSQL_/m', 'DB_', $text);
|
||||
file_put_contents($envFile, $text);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user