diff --git a/config/log/backstage.conf b/config/log/backstage.conf
index 9dc4b172..b7ee05f9 100644
--- a/config/log/backstage.conf
+++ b/config/log/backstage.conf
@@ -6,18 +6,18 @@
MILLISECONDS_WIDTH = 3
PERFORMANCE_TRACKING = false
MAX_LOG_FILE_SIZE = 209715200 ## Throw log files away after 2097152 2MB / 209715200 200MB / 4398046511104 1GB
- FILENAME = "../data/logs/backstage_global_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/backstage_global.log"
* INFO:
LOG_FLUSH_THRESHOLD = 10
- FILENAME = "../data/logs/backstage_info_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/backstage_info.log"
ENABLED = true
* DEBUG:
LOG_FLUSH_THRESHOLD = 0
- FILENAME = "../data/logs/backstage_debug_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/backstage_debug.log"
ENABLED = true
* WARNING:
LOG_FLUSH_THRESHOLD = 0
- FILENAME = "../data/logs/backstage_warn_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/backstage_warn.log"
ENABLED = true
* TRACE:
@@ -27,8 +27,8 @@
* ERROR:
LOG_FLUSH_THRESHOLD = 0
ENABLED = true
- FILENAME = "../data/logs/backstage_error_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/backstage_error.log"
* FATAL:
LOG_FLUSH_THRESHOLD = 0
ENABLED = true
- FILENAME = "../data/logs/backstage_fatal_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/backstage_fatal.log"
diff --git a/config/log/db_proxy.conf b/config/log/db_proxy.conf
index c6bcaa9f..ee8cecb9 100644
--- a/config/log/db_proxy.conf
+++ b/config/log/db_proxy.conf
@@ -6,18 +6,18 @@
MILLISECONDS_WIDTH = 3
PERFORMANCE_TRACKING = false
MAX_LOG_FILE_SIZE = 209715200 ## Throw log files away after 2097152 2MB / 209715200 200MB / 4398046511104 1GB
- FILENAME = "../data/logs/db_proxy_global_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/db_proxy_global.log"
* INFO:
LOG_FLUSH_THRESHOLD = 10
- FILENAME = "../data/logs/db_proxy_info_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/db_proxy_info.log"
ENABLED = true
* DEBUG:
LOG_FLUSH_THRESHOLD = 0
- FILENAME = "../data/logs/db_proxy_debug_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/db_proxy_debug.log"
ENABLED = true
* WARNING:
LOG_FLUSH_THRESHOLD = 0
- FILENAME = "../data/logs/db_proxy_warn_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/db_proxy_warn.log"
ENABLED = true
* TRACE:
@@ -27,8 +27,8 @@
* ERROR:
LOG_FLUSH_THRESHOLD = 0
ENABLED = true
- FILENAME = "../data/logs/db_proxy_error_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/db_proxy_error.log"
* FATAL:
LOG_FLUSH_THRESHOLD = 0
ENABLED = true
- FILENAME = "../data/logs/db_proxy_fatal_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/db_proxy_fatal.log"
diff --git a/config/log/default.conf b/config/log/default.conf
index 5b62f330..89608afa 100644
--- a/config/log/default.conf
+++ b/config/log/default.conf
@@ -6,18 +6,18 @@
MILLISECONDS_WIDTH = 3
PERFORMANCE_TRACKING = false
MAX_LOG_FILE_SIZE = 209715200 ## Throw log files away after 2097152 2MB / 209715200 200MB / 4398046511104 1GB
- FILENAME = "../data/logs/default_global_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/default_global.log"
* INFO:
LOG_FLUSH_THRESHOLD = 10
- FILENAME = "../data/logs/default_info_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/default_info.log"
ENABLED = true
* DEBUG:
LOG_FLUSH_THRESHOLD = 0
- FILENAME = "../data/logs/default_debug_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/default_debug.log"
ENABLED = true
* WARNING:
LOG_FLUSH_THRESHOLD = 0
- FILENAME = "../data/logs/default_warn_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/default_warn.log"
ENABLED = true
* TRACE:
@@ -27,8 +27,8 @@
* ERROR:
LOG_FLUSH_THRESHOLD = 0
ENABLED = true
- FILENAME = "../data/logs/default_error_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/default_error.log"
* FATAL:
LOG_FLUSH_THRESHOLD = 0
ENABLED = true
- FILENAME = "../data/logs/default_fatal_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/default_fatal.log"
diff --git a/config/log/game.conf b/config/log/game.conf
index 1a87984a..a6e98abc 100644
--- a/config/log/game.conf
+++ b/config/log/game.conf
@@ -6,18 +6,18 @@
MILLISECONDS_WIDTH = 3
PERFORMANCE_TRACKING = false
MAX_LOG_FILE_SIZE = 209715200 ## Throw log files away after 2097152 2MB / 209715200 200MB / 4398046511104 1GB
- FILENAME = "../data/logs/game_global_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/game_global.log"
* INFO:
LOG_FLUSH_THRESHOLD = 10
- FILENAME = "../data/logs/game_info_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/game_info.log"
ENABLED = true
* DEBUG:
LOG_FLUSH_THRESHOLD = 0
- FILENAME = "../data/logs/game_debug_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/game_debug.log"
ENABLED = true
* WARNING:
LOG_FLUSH_THRESHOLD = 0
- FILENAME = "../data/logs/game_warn_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/game_warn.log"
ENABLED = true
* TRACE:
@@ -27,8 +27,8 @@
* ERROR:
LOG_FLUSH_THRESHOLD = 0
ENABLED = true
- FILENAME = "../data/logs/game_error_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/game_error.log"
* FATAL:
LOG_FLUSH_THRESHOLD = 0
ENABLED = true
- FILENAME = "../data/logs/game_fatal_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/game_fatal.log"
diff --git a/config/log/game_mgr.conf b/config/log/game_mgr.conf
index 43f5ad3c..dac8f1c2 100644
--- a/config/log/game_mgr.conf
+++ b/config/log/game_mgr.conf
@@ -6,18 +6,18 @@
MILLISECONDS_WIDTH = 3
PERFORMANCE_TRACKING = false
MAX_LOG_FILE_SIZE = 209715200 ## Throw log files away after 2097152 2MB / 209715200 200MB / 4398046511104 1GB
- FILENAME = "../data/logs/game_mgr_global_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/game_mgr_global.log"
* INFO:
LOG_FLUSH_THRESHOLD = 10
- FILENAME = "../data/logs/game_mgr_info_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/game_mgr_info.log"
ENABLED = true
* DEBUG:
LOG_FLUSH_THRESHOLD = 0
- FILENAME = "../data/logs/game_mgr_debug_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/game_mgr_debug.log"
ENABLED = true
* WARNING:
LOG_FLUSH_THRESHOLD = 0
- FILENAME = "../data/logs/game_mgr_warn_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/game_mgr_warn.log"
ENABLED = true
* TRACE:
@@ -27,8 +27,8 @@
* ERROR:
LOG_FLUSH_THRESHOLD = 0
ENABLED = true
- FILENAME = "../data/logs/game_mgr_error_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/game_mgr_error.log"
* FATAL:
LOG_FLUSH_THRESHOLD = 0
ENABLED = true
- FILENAME = "../data/logs/game_mgr_fatal_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/game_mgr_fatal.log"
diff --git a/config/log/master.conf b/config/log/master.conf
index 82c18072..3c3553cd 100644
--- a/config/log/master.conf
+++ b/config/log/master.conf
@@ -6,18 +6,18 @@
MILLISECONDS_WIDTH = 3
PERFORMANCE_TRACKING = false
MAX_LOG_FILE_SIZE = 209715200 ## Throw log files away after 2097152 2MB / 209715200 200MB / 4398046511104 1GB
- FILENAME = "../data/logs/master_global_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/master_global.log"
* INFO:
LOG_FLUSH_THRESHOLD = 10
- FILENAME = "../data/logs/master_info_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/master_info.log"
ENABLED = true
* DEBUG:
LOG_FLUSH_THRESHOLD = 0
- FILENAME = "../data/logs/master_debug_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/master_debug.log"
ENABLED = true
* WARNING:
LOG_FLUSH_THRESHOLD = 0
- FILENAME = "../data/logs/master_warn_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/master_warn.log"
ENABLED = true
* TRACE:
@@ -27,8 +27,8 @@
* ERROR:
LOG_FLUSH_THRESHOLD = 0
ENABLED = true
- FILENAME = "../data/logs/master_error_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/master_error.log"
* FATAL:
LOG_FLUSH_THRESHOLD = 0
ENABLED = true
- FILENAME = "../data/logs/master_fatal_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/master_fatal.log"
diff --git a/config/log/player.conf b/config/log/player.conf
index 06f78531..a679ec10 100644
--- a/config/log/player.conf
+++ b/config/log/player.conf
@@ -6,18 +6,18 @@
MILLISECONDS_WIDTH = 3
PERFORMANCE_TRACKING = false
MAX_LOG_FILE_SIZE = 209715200 ## Throw log files away after 2097152 2MB / 209715200 200MB / 4398046511104 1GB
- FILENAME = "../data/logs/player_global_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/player_global.log"
* INFO:
LOG_FLUSH_THRESHOLD = 10
- FILENAME = "../data/logs/player_info_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/player_info.log"
ENABLED = true
* DEBUG:
LOG_FLUSH_THRESHOLD = 0
- FILENAME = "../data/logs/player_debug_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/player_debug.log"
ENABLED = true
* WARNING:
LOG_FLUSH_THRESHOLD = 0
- FILENAME = "../data/logs/player_warn_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/player_warn.log"
ENABLED = true
* TRACE:
@@ -27,8 +27,8 @@
* ERROR:
LOG_FLUSH_THRESHOLD = 0
ENABLED = true
- FILENAME = "../data/logs/player_error_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/player_error.log"
* FATAL:
LOG_FLUSH_THRESHOLD = 0
ENABLED = true
- FILENAME = "../data/logs/player_fatal_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/player_fatal.log"
diff --git a/config/log/proxy.conf b/config/log/proxy.conf
index 4ae7576b..66c8118a 100644
--- a/config/log/proxy.conf
+++ b/config/log/proxy.conf
@@ -6,18 +6,18 @@
MILLISECONDS_WIDTH = 3
PERFORMANCE_TRACKING = false
MAX_LOG_FILE_SIZE = 209715200 ## Throw log files away after 2097152 2MB / 209715200 200MB / 4398046511104 1GB
- FILENAME = "../data/logs/proxy_global_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/proxy_global.log"
* INFO:
LOG_FLUSH_THRESHOLD = 10
- FILENAME = "../data/logs/proxy_info_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/proxy_info.log"
ENABLED = true
* DEBUG:
LOG_FLUSH_THRESHOLD = 0
- FILENAME = "../data/logs/proxy_debug_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/proxy_debug.log"
ENABLED = true
* WARNING:
LOG_FLUSH_THRESHOLD = 0
- FILENAME = "../data/logs/proxy_warn_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/proxy_warn.log"
ENABLED = true
* TRACE:
@@ -27,8 +27,8 @@
* ERROR:
LOG_FLUSH_THRESHOLD = 0
ENABLED = true
- FILENAME = "../data/logs/proxy_error_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/proxy_error.log"
* FATAL:
LOG_FLUSH_THRESHOLD = 0
ENABLED = true
- FILENAME = "../data/logs/proxy_fatal_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/proxy_fatal.log"
diff --git a/config/log/web.conf b/config/log/web.conf
index d98bfb60..7864bbab 100644
--- a/config/log/web.conf
+++ b/config/log/web.conf
@@ -6,18 +6,18 @@
MILLISECONDS_WIDTH = 3
PERFORMANCE_TRACKING = false
MAX_LOG_FILE_SIZE = 209715200 ## Throw log files away after 2097152 2MB / 209715200 200MB / 4398046511104 1GB
- FILENAME = "../data/logs/web_global_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/web_global.log"
* INFO:
LOG_FLUSH_THRESHOLD = 10
- FILENAME = "../data/logs/web_info_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/web_info.log"
ENABLED = true
* DEBUG:
LOG_FLUSH_THRESHOLD = 0
- FILENAME = "../data/logs/web_debug_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/web_debug.log"
ENABLED = true
* WARNING:
LOG_FLUSH_THRESHOLD = 0
- FILENAME = "../data/logs/web_warn_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/web_warn.log"
ENABLED = true
* TRACE:
@@ -27,8 +27,8 @@
* ERROR:
LOG_FLUSH_THRESHOLD = 0
ENABLED = true
- FILENAME = "../data/logs/web_error_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/web_error.log"
* FATAL:
LOG_FLUSH_THRESHOLD = 0
ENABLED = true
- FILENAME = "../data/logs/web_fatal_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/web_fatal.log"
diff --git a/config/log/world.conf b/config/log/world.conf
index 06ab8515..688ab4a9 100644
--- a/config/log/world.conf
+++ b/config/log/world.conf
@@ -6,18 +6,18 @@
MILLISECONDS_WIDTH = 3
PERFORMANCE_TRACKING = false
MAX_LOG_FILE_SIZE = 209715200 ## Throw log files away after 2097152 2MB / 209715200 200MB / 4398046511104 1GB
- FILENAME = "../data/logs/world_global_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/world_global.log"
* INFO:
LOG_FLUSH_THRESHOLD = 10
- FILENAME = "../data/logs/world_info_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/world_info.log"
ENABLED = true
* DEBUG:
LOG_FLUSH_THRESHOLD = 0
- FILENAME = "../data/logs/world_debug_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/world_debug.log"
ENABLED = true
* WARNING:
LOG_FLUSH_THRESHOLD = 0
- FILENAME = "../data/logs/world_warn_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/world_warn.log"
ENABLED = true
* TRACE:
@@ -27,8 +27,8 @@
* ERROR:
LOG_FLUSH_THRESHOLD = 0
ENABLED = true
- FILENAME = "../data/logs/world_error_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/world_error.log"
* FATAL:
LOG_FLUSH_THRESHOLD = 0
ENABLED = true
- FILENAME = "../data/logs/world_fatal_%datetime{%Y%M%d}.log"
+ FILENAME = "../data/logs/world_fatal.log"
diff --git a/config/node/backstage.json b/config/node/backstage.json
new file mode 100644
index 00000000..53951a4a
--- /dev/null
+++ b/config/node/backstage.json
@@ -0,0 +1,15 @@
+{
+ "ResponseHttpHeader": {
+ "Access-Control-Allow-Origin" : "http://localhost:5173",
+ "Access-Control-Allow-Headers" : "Content-Type,Access-Token,X-CSRF-Token, Authorization",
+ "Access-Control-Allow-Methods" : "POST,GET,OPTIONS,PUT",
+ "Access-Control-Expose-Headers" : "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers, Content-Type",
+ "Access-Control-Allow-Credentials" : "true"
+ },
+
+ "WhiteUriList" : [
+ "/api/login",
+ "/api/reload",
+ "/api/execute_lua"
+ ]
+}
diff --git a/config/node/base.json b/config/node/base.json
new file mode 100644
index 00000000..07fa4878
--- /dev/null
+++ b/config/node/base.json
@@ -0,0 +1,12 @@
+{
+ "is_online_version" : false,
+ "protocol_debug": true,
+ "protocol_timeout_check": true,
+ "coroutine_max_num" : 10000,
+ "is_enable_https": false,
+ "max_connection": 10000,
+ "ssl_file" : {
+ "certificate" : "../config/ssl/certificate.pem",
+ "private_key" : "../config/ssl/private-key.pem"
+ }
+}
\ No newline at end of file
diff --git a/config/node/db.json b/config/node/db.json
index 4ad30dd3..eabfbace 100644
--- a/config/node/db.json
+++ b/config/node/db.json
@@ -1,14 +1,14 @@
{
"Mysql" : {
- "Account" : { "ip":"127.0.0.1", "port":10400, "user":"root", "password":"pwnsky_squick", "database":"db_account"}
+ "Account" : { "ip":"9.134.247.53", "port":10400, "user":"root", "password":"pwnsky_squick", "database":"db_account" }
},
"Mongo" : {
- "Player" : { "ip":"127.0.0.1", "port":10410, "user":"admin", "password":"pwnsky_squick", "database":"db_game"}
+ "Player" : { "ip":"9.134.247.53", "port":10410, "user":"admin", "password":"pwnsky_squick", "database":"db_game"}
},
"Redis" : {
- "Cache" : { "ip":"127.0.0.1", "port":10420, "user":"root", "password":"pwnsky_squick", "database":""}
+ "Cache" : { "ip":"9.134.247.53", "port":10420, "user":"root", "password":"pwnsky_squick", "database":""}
},
"Clickhouse" : {
- "Log" : { "ip":"127.0.0.1", "port":10431, "user":"default", "password":"pwnsky_squick", "database":"db_log"}
+ "Log" : { "ip":"9.134.247.53", "port":10431, "user":"default", "password":"pwnsky_squick", "database":"db_log"}
}
-}
\ No newline at end of file
+}
diff --git a/config/node/web.json b/config/node/web.json
index a391bdc9..0db3279e 100644
--- a/config/node/web.json
+++ b/config/node/web.json
@@ -1,13 +1,3 @@
{
- "ResponseHttpHeader": {
- "Access-Control-Allow-Origin" : "http://localhost:5173",
- "Access-Control-Allow-Headers" : "Content-Type,Access-Token,X-CSRF-Token, Authorization",
- "Access-Control-Allow-Methods" : "POST,GET,OPTIONS,PUT",
- "Access-Control-Expose-Headers" : "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers, Content-Type",
- "Access-Control-Allow-Credentials" : "true"
- },
-
- "WhiteUriList" : [
- "/api/login"
- ]
-}
\ No newline at end of file
+
+}
diff --git a/config/tmpl/backstage.json b/config/tmpl/backstage.json
new file mode 100644
index 00000000..53951a4a
--- /dev/null
+++ b/config/tmpl/backstage.json
@@ -0,0 +1,15 @@
+{
+ "ResponseHttpHeader": {
+ "Access-Control-Allow-Origin" : "http://localhost:5173",
+ "Access-Control-Allow-Headers" : "Content-Type,Access-Token,X-CSRF-Token, Authorization",
+ "Access-Control-Allow-Methods" : "POST,GET,OPTIONS,PUT",
+ "Access-Control-Expose-Headers" : "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers, Content-Type",
+ "Access-Control-Allow-Credentials" : "true"
+ },
+
+ "WhiteUriList" : [
+ "/api/login",
+ "/api/reload",
+ "/api/execute_lua"
+ ]
+}
diff --git a/config/tmpl/base.json b/config/tmpl/base.json
new file mode 100644
index 00000000..07fa4878
--- /dev/null
+++ b/config/tmpl/base.json
@@ -0,0 +1,12 @@
+{
+ "is_online_version" : false,
+ "protocol_debug": true,
+ "protocol_timeout_check": true,
+ "coroutine_max_num" : 10000,
+ "is_enable_https": false,
+ "max_connection": 10000,
+ "ssl_file" : {
+ "certificate" : "../config/ssl/certificate.pem",
+ "private_key" : "../config/ssl/private-key.pem"
+ }
+}
\ No newline at end of file
diff --git a/config/tmpl/db.json b/config/tmpl/db.json
new file mode 100644
index 00000000..4ec643f9
--- /dev/null
+++ b/config/tmpl/db.json
@@ -0,0 +1,14 @@
+{
+ "Mysql" : {
+ "Account" : { "ip":"{mysql_account_ip}", "port":{mysql_account_port}, "user":"root", "password":"pwnsky_squick", "database":"db_account" }
+ },
+ "Mongo" : {
+ "Player" : { "ip":"{mongo_player_ip}", "port":{mongo_player_port}, "user":"admin", "password":"pwnsky_squick", "database":"db_game"}
+ },
+ "Redis" : {
+ "Cache" : { "ip":"{redis_cache_ip}", "port":{redis_cache_port}, "user":"root", "password":"pwnsky_squick", "database":""}
+ },
+ "Clickhouse" : {
+ "Log" : { "ip":"{clickhouse_log_ip}", "port":{clickhouse_log_port}, "user":"default", "password":"pwnsky_squick", "database":"db_log"}
+ }
+}
diff --git a/config/tmpl/env/dev.conf b/config/tmpl/env/dev.conf
new file mode 100644
index 00000000..e9436343
--- /dev/null
+++ b/config/tmpl/env/dev.conf
@@ -0,0 +1,8 @@
+mysql_account_ip=127.0.0.1
+mysql_account_port=10400
+mongo_player_ip=127.0.0.1
+mongo_player_port=10410
+redis_cache_ip=127.0.0.1
+redis_cache_port=10420
+clickhouse_log_ip=127.0.0.1
+clickhouse_log_port=10431
diff --git a/config/tmpl/env/docker_dev.conf b/config/tmpl/env/docker_dev.conf
new file mode 100644
index 00000000..f444a5e7
--- /dev/null
+++ b/config/tmpl/env/docker_dev.conf
@@ -0,0 +1,8 @@
+mysql_account_ip=172.0.0.60
+mysql_account_port=33060
+mongo_player_ip=172.0.0.61
+mongo_player_port=27017
+redis_cache_ip=172.0.0.62
+redis_cache_port=6379
+clickhouse_log_ip=172.0.0.63
+clickhouse_log_port=9000
diff --git a/config/tmpl/env/online.conf b/config/tmpl/env/online.conf
new file mode 100644
index 00000000..e9436343
--- /dev/null
+++ b/config/tmpl/env/online.conf
@@ -0,0 +1,8 @@
+mysql_account_ip=127.0.0.1
+mysql_account_port=10400
+mongo_player_ip=127.0.0.1
+mongo_player_port=10410
+redis_cache_ip=127.0.0.1
+redis_cache_port=10420
+clickhouse_log_ip=127.0.0.1
+clickhouse_log_port=10431
diff --git a/config/tmpl/env/ten.conf b/config/tmpl/env/ten.conf
new file mode 100644
index 00000000..f05fa645
--- /dev/null
+++ b/config/tmpl/env/ten.conf
@@ -0,0 +1,8 @@
+mysql_account_ip=9.134.247.53
+mysql_account_port=10400
+mongo_player_ip=9.134.247.53
+mongo_player_port=10410
+redis_cache_ip=9.134.247.53
+redis_cache_port=10420
+clickhouse_log_ip=9.134.247.53
+clickhouse_log_port=10431
diff --git a/config/tmpl/web.json b/config/tmpl/web.json
new file mode 100644
index 00000000..0db3279e
--- /dev/null
+++ b/config/tmpl/web.json
@@ -0,0 +1,3 @@
+{
+
+}
diff --git a/docker/build_image.sh b/docker/build_image.sh
new file mode 100755
index 00000000..17c72deb
--- /dev/null
+++ b/docker/build_image.sh
@@ -0,0 +1,37 @@
+#! /bin/bash
+
+cd $(dirname $0)
+source ../tools/common.sh
+
+build_type='docker'
+is_build_third_party=0
+is_build_sqkctl=0
+src_image_tag=pwnsky/squick_src:1.1
+bin_image_tag=pwnsky/squick:1.1
+build_container=squick_src_build
+
+cd $project_path
+
+echo "Build src image"
+docker build . -t $src_image_tag -f ./docker/src
+check_err
+
+echo "Export binary files"
+docker run -d --name $build_container $src_image_tag
+check_err
+rm -rf ./cache/docker_deploy
+docker cp $build_container:/squick/deploy ./cache/docker_deploy
+check_err
+
+echo "Clean src build env"
+docker stop $build_container
+check_err
+docker rm $build_container
+check_err
+
+echo "Build release image"
+docker build . -t $bin_image_tag -f ./docker/release
+check_err
+
+echo "Build image ok"
+print_ok
diff --git a/docker/single.yml b/docker/single.yml
index 9d6b93c6..e82edc76 100644
--- a/docker/single.yml
+++ b/docker/single.yml
@@ -3,80 +3,143 @@ services:
master:
build:
context: .
- image: i0gan/squick:1.1
+ image: pwnsky/squick:1.1
user: root
restart: always
- ports:
- - 8888:8888
environment:
- - SQUICK_ARGS=type=master id=1 area=0 ip=127.0.0.1 port=10001 web_port=8888
+ - SQUICK_ARGS=type=master id=1 area=0 ip=172.0.0.1 port=10001 web_port=8888
networks:
- default:
- internal:
+ squick_net:
+ ipv4_address: 172.0.0.10
- world:
+ db_proxy:
build:
context: .
- image: i0gan/squick:1.1
+ image: pwnsky/squick:1.1
user: root
restart: always
environment:
- - SQUICK_ARGS=type=world id=100 area=0 ip=127.0.0.1 port=10101 master_ip=127.0.0.1 master_port=10001
+ - SQUICK_ARGS=type=db_proxy id=300 area=0 ip=172.0.0.3 port=10201 master_ip=172.0.0.1 master_port=10001
networks:
- default:
- internal:
+ squick_net:
+ ipv4_address: 172.0.0.11
- db_proxy:
+ world:
build:
context: .
- image: i0gan/squick:1.1
+ image: pwnsky/squick:1.1
user: root
restart: always
environment:
- - SQUICK_ARGS=type=db_proxy id=300 area=0 ip=127.0.0.1 port=10201 master_ip=127.0.0.1 master_port=10001
+ - SQUICK_ARGS=type=world id=100 area=0 ip=172.0.0.2 port=10101 master_ip=172.0.0.1 master_port=10001
networks:
- default:
- internal:
+ squick_net:
+ ipv4_address: 172.0.0.12
- login:
+ web:
build:
context: .
- image: i0gan/squick:1.1
+ image: pwnsky/squick:1.1
user: root
restart: always
ports:
- 8080:80
environment:
- - SQUICK_ARGS=type=login id=2 area=0 ip=127.0.0.1 port=10301 web_port=80 master_ip=127.0.0.1 master_port=10001
+ - SQUICK_ARGS=type=web id=2 area=0 ip=172.0.0.4 port=10301 web_port=80 master_ip=172.0.0.1 master_port=10001
networks:
- default:
- internal:
+ squick_net:
+ ipv4_address: 172.0.0.13
- lobby:
+ player:
build:
context: .
- image: i0gan/squick:1.1
+ image: pwnsky/squick:1.1
user: root
restart: always
environment:
- - SQUICK_ARGS=type=lobby id=1000 area=0 ip=127.0.0.1 port=10401 master_ip=127.0.0.1 master_port=10001
+ - SQUICK_ARGS=type=player id=1000 area=0 ip=172.0.0.5 port=10401 master_ip=172.0.0.1 master_port=10001
networks:
- default:
- internal:
+ squick_net:
+ ipv4_address: 172.0.0.14
proxy1:
build:
context: .
- image: i0gan/squick:1.1
+ image: pwnsky/squick:1.1
+ user: root
+ restart: always
+ environment:
+ - SQUICK_ARGS=type=proxy id=500 area=0 ip=172.0.0.6 port=10501 master_ip=172.0.0.1 master_port=10001
+ networks:
+ squick_net:
+ ipv4_address: 172.0.0.15
+
+ backstage:
+ build:
+ context: .
+ image: pwnsky/squick:1.1
+ user: root
+ restart: always
+ ports:
+ - 8888:80
+ environment:
+ - SQUICK_ARGS=type=backstage id=10 area=0 ip=172.0.0.7 port=10401 web_port=80 master_ip=172.0.0.1 master_port=10001
+ networks:
+ squick_net:
+ ipv4_address: 172.0.0.16
+
+ db_mysql:
+ build:
+ context: .
+ image: mysql:8.0
+ user: root
+ restart: always
+ environment:
+ - MYSQL_ROOT_PASSWORD=pwnsky_squick
+ networks:
+ squick_net:
+ ipv4_address: 172.0.0.60
+
+ db_mongo:
+ build:
+ context: .
+ image: mongo:6.0.5
+ user: root
+ restart: always
+ environment:
+ - MONGO_INITDB_ROOT_USERNAME=admin
+ - MONGO_INITDB_ROOT_PASSWORD=pwnsky_squick
+ networks:
+ squick_net:
+ ipv4_address: 172.0.0.61
+
+ db_clickhouse:
+ build:
+ context: .
+ image: clickhouse/clickhouse-server:23.1.3.5-alpine
+ user: root
+ restart: always
+ networks:
+ squick_net:
+ ipv4_address: 172.0.0.62
+
+ db_redis:
+ build:
+ context: .
+ image: redis:7.0
user: root
restart: always
environment:
- - SQUICK_ARGS=type=proxy id=500 area=0 ip=127.0.0.1 port=10501 master_ip=127.0.0.1 master_port=10001
+ - REDIS_PASSWORD=pwnsky_squick
networks:
- default:
- internal:
+ squick_net:
+ ipv4_address: 172.0.0.63
networks:
default:
internal:
- internal: true
\ No newline at end of file
+ internal: true
+ squick_net:
+ ipam:
+ config:
+ - subnet: 172.0.0.0/16
diff --git a/docker/stop_all.sh b/docker/stop_all.sh
new file mode 100755
index 00000000..20da1e8d
--- /dev/null
+++ b/docker/stop_all.sh
@@ -0,0 +1,10 @@
+#! /bin/bash
+
+array=("web" "proxy1" "player" "world" "backstage" "master" "db_proxy" "db_mysql" "db_redis" "db_mongo" "db_clickhouse")
+
+for i in "${array[@]}"; do
+ container_name="docker-$i-1"
+ echo "del $container_name"
+ docker kill $container_name
+ docker rm $container_name
+done
diff --git a/kubernetes/gen_k8s_config.sh b/kubernetes/gen_k8s_config.sh
new file mode 100755
index 00000000..99b989f0
--- /dev/null
+++ b/kubernetes/gen_k8s_config.sh
@@ -0,0 +1,6 @@
+#! /bin/bash
+
+namespace="pwnsky"
+image="pwnsky"
+
+
diff --git a/kubernetes/load_image_from_docker.sh b/kubernetes/load_image_from_docker.sh
new file mode 100755
index 00000000..0b6cbf48
--- /dev/null
+++ b/kubernetes/load_image_from_docker.sh
@@ -0,0 +1,11 @@
+#! /bin/bash
+#kind load docker-image pwnsky/squick:1.1
+
+docker_image=pwnsky/squick:1.1
+
+echo "Save image from docker"
+docker save $docker_image > /tmp/squick.tar
+echo "Import image"
+ctr -n k8s.io image import /tmp/squick.tar
+ctr -n k8s.io image list | grep squick
+echo "Import ok"
diff --git a/kubernetes/node/master.yaml b/kubernetes/node/master.yaml
index be624978..ed71fb35 100644
--- a/kubernetes/node/master.yaml
+++ b/kubernetes/node/master.yaml
@@ -8,7 +8,7 @@ metadata:
app: squick
spec:
serviceName: "svc-squick-master"
- replicas: 1
+ replicas: 2
selector:
matchLabels:
app: squick
@@ -19,7 +19,7 @@ spec:
spec:
containers:
- name: squick
- image: i0gan/squick:1.1
+ image: pwnsky/squick:1.1
imagePullPolicy: Never
command: ["/bin/bash", "-c"]
args:
@@ -37,4 +37,4 @@ spec:
- name: POD_NAMESPACE
valueFrom:
fieldRef:
- fieldPath: metadata.namespace
\ No newline at end of file
+ fieldPath: metadata.namespace
diff --git a/script/env.sh b/script/env.sh
new file mode 100755
index 00000000..d20357cd
--- /dev/null
+++ b/script/env.sh
@@ -0,0 +1,4 @@
+#! /bin/bash
+export SQUICK_ARGS=""
+export SQUICK_NOT_GEN_CONFIG=false
+export SQUICK_RUN_ENV=ten
diff --git a/script/gen_env_config.sh b/script/gen_env_config.sh
new file mode 100755
index 00000000..6d508f62
--- /dev/null
+++ b/script/gen_env_config.sh
@@ -0,0 +1,47 @@
+#! /bin/bash
+
+cd $(dirname $0)
+
+if [[ $SQUICK_NOT_GEN_CONFIG == "true" ]];then
+ exit
+fi
+
+if [ -z $SQUICK_RUN_ENV ];then
+ SQUICK_RUN_ENV="dev"
+fi
+
+echo "Run env: $SQUICK_RUN_ENV"
+
+out_path="../config/node"
+tmpl_path="../config/tmpl"
+conf_file="$tmpl_path/env/$SQUICK_RUN_ENV.conf"
+
+echo "Clean old env config"
+rm -rf $out_path
+
+files=()
+while IFS= read -r file; do
+ if [[ $file != "env" ]];then
+ files+=("$file")
+ fi
+done < <(ls $tmpl_path)
+
+echo "Gen env config..."
+mkdir -p $out_path
+
+echo "replacing ..."
+
+sed_cmd="sed"
+while IFS= read -r line
+do
+ key={`echo $line | awk '{split($0, a, "="); print a[1]}'`}
+ value=`echo $line | awk '{split($0, a, "="); print a[2]}'`
+ sed_cmd+=" -e 's/$key/$value/g'"
+done < "$conf_file"
+
+# search
+for file in "${files[@]}"; do
+ tmpl_file="$tmpl_path/$file"
+ bash -c "cat $tmpl_file | $sed_cmd $tmpl_file" > $out_path/$file
+done
+echo "Gen cfg ok"
diff --git a/script/reload.sh b/script/reload.sh
new file mode 100755
index 00000000..d62f0cb1
--- /dev/null
+++ b/script/reload.sh
@@ -0,0 +1,22 @@
+#! /bin/bash
+# reload json config
+
+API_URL="http://127.0.0.1:8888/api/reload"
+API_SALT=pwnsky_squick
+
+
+echo -e "\nreloading node config"
+sleep 1
+curl $API_URL?type=node
+
+
+echo -e "\nreloading xml config"
+sleep 1
+curl $API_URL?type=xml
+
+
+echo -e "\nreloading lua script"
+sleep 1
+curl $API_URL?type=lua
+
+echo -e "\nall config and script reloaded"
diff --git a/script/run_lua.py b/script/run_lua.py
new file mode 100644
index 00000000..be72fe37
--- /dev/null
+++ b/script/run_lua.py
@@ -0,0 +1,34 @@
+import requests
+import json
+
+url = 'http://127.0.0.1:8888/api/execute_lua'
+
+data = {
+ 'node_id': 1000,
+ 'script': 'return print_t(ModuleMgr)',
+ 'type': 0
+}
+
+global_env = '''
+Lua debug console
+The global table symble:
+Env
+ModuleMgr
+'''
+print(global_env)
+print('Example: print_t(Env)')
+
+def check_input(user_input):
+ real_inpurt = ''
+ if 'return' not in user_input:
+ real_input = 'return ' + user_input
+ return real_input
+
+
+while True:
+ user_input = input("lua: ")
+ data['script'] = check_input(user_input)
+ #print(user_input)
+ response = requests.post(url, data=json.dumps(data))
+ output = json.loads(response.text)
+ print(output['output'])
diff --git a/script/setup_db.sh b/script/setup_db.sh
new file mode 100755
index 00000000..19ae6602
--- /dev/null
+++ b/script/setup_db.sh
@@ -0,0 +1,19 @@
+#! /bin/bash
+
+echo "set up mysql"
+docker run -d --restart always --name squick_db_mysql_1 -p 10400:33060 -e MYSQL_ROOT_PASSWORD=pwnsky_squick mysql:8.0
+
+echo "set up mongo"
+docker run -d --restart always --name squick_db_mongo_1 -p 10410:27017 -e MONGO_INITDB_ROOT_USERNAME=admin -e MONGO_INITDB_ROOT_PASSWORD=pwnsky_squick mongo:6.0.5 mongod --auth
+
+echo "set up redis"
+docker run -d --restart always --name squick_db_redis_1 -p 10420:6379 redis:7.0 --requirepass pwnsky_squick
+
+echo "set up clickhouse"
+docker run -d --restart always --name squick_db_clickhouse_1 -p 10430:8123 -p 10431:9000 -p 10432:9009 clickhouse/clickhouse-server:23.1.3.5-alpine
+
+echo "please set the db password in clickhouse"
+echo "Find "
+echo "Add the password(pwnsky_squick) in the middle"
+sleep 3
+docker exec -it squick_db_clickhouse_1 vi /etc/clickhouse-server/users.xml
diff --git a/script/squick.sh b/script/squick.sh
index d03e77fd..9432c9a1 100755
--- a/script/squick.sh
+++ b/script/squick.sh
@@ -8,6 +8,8 @@ cd $(dirname $0)
ulimit -c unlimited
+bash ./gen_env_config.sh
+
cd ../bin
# for linux
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`pwd`/lib
@@ -19,4 +21,4 @@ if [ -z $SQUICK_ARGS ];then
./squick $@
else
./squick $SQUICK_ARGS
-fi
\ No newline at end of file
+fi
diff --git a/script/start.sh b/script/start.sh
index fde0b1de..618a2fbd 100755
--- a/script/start.sh
+++ b/script/start.sh
@@ -7,6 +7,9 @@
cd $(dirname $0)
log_path="../data/logs"
+bash ./gen_env_config.sh
+export SQUICK_NOT_GEN_CONFIG="true"
+
./squick.sh type=master id=1 area=0 ip=127.0.0.1 port=10001 http_port=50000 logshow=0 >> $log_path/master_run.log &
sleep 0.5
./squick.sh type=backstage id=10 area=0 ip=127.0.0.1 port=10010 http_port=8888 master_ip=127.0.0.1 master_port=10001 logshow=0 >> $log_path/backstage_run.log &
diff --git a/src/lua/common/print_table.lua b/src/lua/common/print_table.lua
index c1631aa1..b80f254d 100644
--- a/src/lua/common/print_table.lua
+++ b/src/lua/common/print_table.lua
@@ -5,37 +5,52 @@
-- Description: 打印table
-----------------------------------------------------------------------------
-function PrintTable(table)
+function print_t(table, level)
+ local out_str = ""
if table == nil then
- print("the table is nil");
- print(debug.traceback())
- return;
+ out_str = out_str .. "the table is nil\n"
+ out_str = out_str .. debug.traceback()
+ return out_str
+ end
+
+ if level == nil then
+ level = 1
end
+
+ if level > 10 then
+ return ''
+ end
local key = ""
- level = 1
+
local indent = ""
for i = 1, level do
- indent = indent.." "
+ indent = indent .. " "
end
if key ~= "" then
- print(indent..key.." ".."=".." ".."{")
+ out_str = out_str .. indent .. key.." ".."=".." ".."{\n"
else
- print(indent .. "{")
+ out_str = out_str .. indent .. "{\n"
end
key = ""
for k,v in pairs(table) do
if type(v) == "table" then
key = k
- print(indent .. key .. " =")
- PrintTable(v, level + 1)
+ out_str = out_str .. indent .. key .. " =\n"
+ out_str = out_str .. print_t(v, level + 1)
else
local content = string.format("%s%s = %s", indent .. " ",tostring(k), tostring(v))
- print(content..";")
+ out_str = out_str .. content..";\n"
end
end
- print(indent .. "}")
+ out_str = out_str .. indent .. "}\n"
+
+ return out_str
+end
+
+function PrintTable(table)
+ print(print_t(table))
+end
-end
\ No newline at end of file
diff --git a/src/lua/main.lua b/src/lua/main.lua
index 64c4bc82..dff3b2da 100644
--- a/src/lua/main.lua
+++ b/src/lua/main.lua
@@ -64,7 +64,9 @@ function Destroy()
end
function HotReload()
+ Squick:LogInfo("Lua script begin hot reload")
Load()
+ Squick:LogInfo("Lua script end hot reload")
end
function Load()
@@ -85,3 +87,9 @@ function Load()
Print("Not surppot this app type: " .. tostring(Env.app_type))
end
end
+
+-- Execute lua code
+function ExecuteLua(script_code)
+ local func = load(script_code)
+ return tostring(func())
+end
\ No newline at end of file
diff --git a/src/main.cc b/src/main.cc
index 5e78078f..77abba66 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -107,13 +107,12 @@ int main(int argc, char *argv[]) {
strArgvList += argv[i];
}
- PrintLogo();
-
if (argc == 1) {
#ifdef SQUICK_DEV
DefaultStartUp(strArgvList, serverList);
// TutorialStartUp(strArgvList, serverList);
#else
+ PrintLogo();
SQUICK_PRINT("<< Squick Help >>\n"
"Squick args usage:\n"
" type: Set your app type; default: proxy\n"
@@ -153,8 +152,17 @@ int main(int argc, char *argv[]) {
while (squick_loop_) {
nIndex++;
SetSquickMainThreadSleep(true);
+ int state = GetSquickReloadState();
for (auto item : serverList) {
item->Update();
+ if (state > 0)
+ {
+ item->Reload(state);
+ }
+ }
+ if (state > 0)
+ {
+ SetSquickReloadState(0);
}
if (IsSquickMainThreadSleep()) {
std::this_thread::sleep_for(std::chrono::milliseconds(MAIN_THREAD_SLEEP_TIME));
diff --git a/src/node/backstage/logic/logic_module.cc b/src/node/backstage/logic/logic_module.cc
index 3aa16732..b5e35d08 100644
--- a/src/node/backstage/logic/logic_module.cc
+++ b/src/node/backstage/logic/logic_module.cc
@@ -3,13 +3,12 @@
#include
#include
-#include
-#include
-#include
-
#define SQUICK_HASH_SALT "7e82e88dfd98952b713c0d20170ce12b"
#define WEB_BASE_PATH "/api"
+
+
namespace backstage::logic {
+
bool LogicModule::Start() {
m_http_server_ = pm_->FindModule();
m_node_ = pm_->FindModule();
@@ -28,9 +27,11 @@ bool LogicModule::AfterStart() {
m_http_server_->AddRequestHandler(WEB_BASE_PATH "/all_nodes", HttpType::SQUICK_HTTP_REQ_GET, this, &LogicModule::OnGetAllNodes);
m_http_server_->AddRequestHandler(WEB_BASE_PATH "/auth_check", HttpType::SQUICK_HTTP_REQ_POST, this, &LogicModule::OnAuthCheck);
m_http_server_->AddRequestHandler(WEB_BASE_PATH "/auth_check", HttpType::SQUICK_HTTP_REQ_GET, this, &LogicModule::OnAuthCheck);
+ m_http_server_->AddRequestHandler(WEB_BASE_PATH "/reload", HttpType::SQUICK_HTTP_REQ_GET, this, &LogicModule::OnReload);
+ m_http_server_->AddRequestHandler(WEB_BASE_PATH "/execute_lua", HttpType::SQUICK_HTTP_REQ_POST, this, &LogicModule::OnLuaExecute);
m_http_server_->StartServer(pm_->GetArg("http_port=", ARG_DEFAULT_HTTP_PORT));
- vector node_types = {rpc::ST_GLOBAL, rpc::ST_DB_PROXY, rpc::ST_PLAYER};
+ vector node_types = {rpc::ST_GLOBAL, rpc::ST_DB_PROXY, rpc::ST_PLAYER, rpc::ST_PROXY, rpc::ST_WORLD, rpc::ST_WEB};
m_node_->AddSubscribeNode(node_types);
LoadConfig();
@@ -38,7 +39,7 @@ bool LogicModule::AfterStart() {
}
bool LogicModule::LoadConfig() {
- std::string config_path = pm_->GetWorkPath() + "/config/node/web.json";
+ std::string config_path = pm_->GetWorkPath() + "/config/node/backstage.json";
std::ifstream config_file(config_path);
if (!config_file.is_open()) {
LOG_ERROR("The configure file <%v> is not exsist", config_path);
@@ -80,6 +81,38 @@ bool LogicModule::OnAuthCheck(std::shared_ptr request) {
return true;
}
+Coroutine LogicModule::OnReload(std::shared_ptr request) {
+
+ IResponse rsp;
+ rpc::NReqReload pbreq;
+ auto data = co_await m_net_client_->RequestPB(DEFAULT_MASTER_ID, rpc::IdNReqReload, pbreq, rpc::IdNAckReload);
+ if (data.error) {
+ rsp.code = IResponse::SERVER_ERROR;
+ rsp.msg = "Server get network error";
+ ajson::string_stream rep_ss;
+ ajson::save_to(rep_ss, rsp);
+ m_http_server_->ResponseMsg(request, rep_ss.str(), WebStatus::WEB_ERROR);
+ co_return;
+ }
+
+ uint64_t uid;
+ rpc::NAckReload pback;
+ if (!INetModule::ReceivePB(data.ack_msg_id, data.data, data.length, pback, uid)) {
+ rsp.code = IResponse::SERVER_ERROR;
+ rsp.msg = "Parse msg is error error";
+ ajson::string_stream rep_ss;
+ ajson::save_to(rep_ss, rsp);
+ m_http_server_->ResponseMsg(request, rep_ss.str(), WebStatus::WEB_ERROR);
+ co_return;
+ }
+
+ rsp.code = IResponse::SUCCESS;
+ rsp.msg = "reloaded";
+ ajson::string_stream rep_ss;
+ ajson::save_to(rep_ss, rsp);
+ m_http_server_->ResponseMsg(request, rep_ss.str(), WebStatus::WEB_OK);
+}
+
Coroutine LogicModule::OnLogin(std::shared_ptr request) {
std::string res_str;
BkReqLogin req;
@@ -233,6 +266,16 @@ string LogicModule::MakeToken(string account_id) {
void LogicModule::SetToken(const std::string &account_id, const std::string &user_token) { auth_token_[account_id] = user_token; }
+util::JsonPrintOptions LogicModule::GetDefaultPb2JsonOptions() {
+ google::protobuf::util::JsonPrintOptions options;
+ options.preserve_proto_field_names = true;
+ options.always_print_primitive_fields = true;
+ options.always_print_enums_as_ints = true;
+ options.add_whitespace = true;
+ return options;
+}
+
+
Coroutine LogicModule::OnGetAllNodes(std::shared_ptr request) {
json rsp;
@@ -262,14 +305,8 @@ Coroutine LogicModule::OnGetAllNodes(std::shared_ptr request)
// protobuf 转 json-string
util::Status google::protobuf::util::MessageToJsonString(const google::protobuf::Message& message, std::string* str );
*/
-
- google::protobuf::util::JsonPrintOptions options;
- options.preserve_proto_field_names = true;
- options.always_print_primitive_fields = true;
- options.always_print_enums_as_ints = true;
- options.add_whitespace = true;
std::string json_out;
- google::protobuf::util::Status status = google::protobuf::util::MessageToJsonString(pback, &json_out, options);
+ google::protobuf::util::Status status = google::protobuf::util::MessageToJsonString(pback, &json_out, GetDefaultPb2JsonOptions());
LOG_DEBUG("Protobuf to json: %v", json_out);
nlohmann::json node_list = nlohmann::json::array();
@@ -299,4 +336,33 @@ Coroutine LogicModule::OnGetAllNodes(std::shared_ptr request)
m_http_server_->ResponseMsg(request, rsp.dump(), WebStatus::WEB_OK);
co_return;
}
+
+Coroutine LogicModule::OnLuaExecute(std::shared_ptr request) {
+
+ rpc::NReqExecuteLua pbreq;
+ rpc::NAckExecuteLua pback;
+ util::Status status = util::JsonStringToMessage(request->body, &pbreq);
+ if (!status.ok())
+ {
+ LOG_ERROR("Pasrse the json string is error, status", (int)status.code());
+ }
+
+ auto data = co_await m_net_client_->RequestPB(pbreq.node_id(), rpc::IdNReqExecuteLua, pbreq, rpc::IdNAckExecuteLua);
+ if (data.error) {
+ LOG_ERROR("Corotuine request is error", 0);
+ co_return;
+ }
+
+ uint64_t uid;
+ if (!INetModule::ReceivePB(data.ack_msg_id, data.data, data.length, pback, uid)) {
+ co_return;
+ }
+
+ std::string json_out;
+ status = util::MessageToJsonString(pback, &json_out, GetDefaultPb2JsonOptions());
+ LOG_DEBUG("OnLuaExecute Protobuf to json: %v", json_out);
+
+ m_http_server_->ResponseMsg(request, json_out, WebStatus::WEB_OK);
+}
+
} // namespace backstage::logic
diff --git a/src/node/backstage/logic/logic_module.h b/src/node/backstage/logic/logic_module.h
index 4b77c4d4..7607f651 100644
--- a/src/node/backstage/logic/logic_module.h
+++ b/src/node/backstage/logic/logic_module.h
@@ -9,9 +9,12 @@
#include
#include
#include
-
+#include
+#include
+#include
namespace backstage::logic {
+using namespace google::protobuf;
struct LoginInfo {
std::string account;
std::string account_id;
@@ -41,8 +44,15 @@ class LogicModule : public ILogicModule {
void SetToken(const std::string &account_id, const std::string &user_token);
bool LoadConfig();
+
+ util::JsonPrintOptions GetDefaultPb2JsonOptions();
+
+ // http handler
bool OnAuthCheck(std::shared_ptr request);
Coroutine OnGetAllNodes(std::shared_ptr request);
+ Coroutine OnReload(std::shared_ptr request);
+ Coroutine OnLuaExecute(std::shared_ptr request);
+
private:
string MakeToken(string sguid);
@@ -62,5 +72,4 @@ class LogicModule : public ILogicModule {
int player_index = 0;
json web_config_;
};
-
-} // namespace backstage::logic
\ No newline at end of file
+} // namespace backstage::logic
diff --git a/src/node/db_proxy/redis/redis_module.cc b/src/node/db_proxy/redis/redis_module.cc
index 3302acc5..28dc03f3 100644
--- a/src/node/db_proxy/redis/redis_module.cc
+++ b/src/node/db_proxy/redis/redis_module.cc
@@ -131,7 +131,6 @@ bool RedisModule::Connect() {
try {
// Create an Redis object, which is movable but NOT copyable.
string url = "tcp://" + ip_ + ":" + to_string(port_);
- dout << "connect to : " << url << std::endl;
client_ = new Redis(url);
client_->auth(password_);
diff --git a/src/node/ds_mgr/logic/logic_module.cc b/src/node/ds_mgr/logic/logic_module.cc
index 3251d3f7..081d481e 100644
--- a/src/node/ds_mgr/logic/logic_module.cc
+++ b/src/node/ds_mgr/logic/logic_module.cc
@@ -50,7 +50,7 @@ void LogicModule::OnReqPvpInstanceCreate(const socket_t sock, const int msg_id,
return;
}
- dout << "Game Server 请求创建PVP实例 from " << xMsg.game_id() << " id: " << xMsg.id() << " key: " << xMsg.key() << std::endl;
+ // dout << "Game Server 请求创建PVP实例 from " << xMsg.game_id() << " id: " << xMsg.id() << " key: " << xMsg.key() << std::endl;
string cmd;
// 为了测试方便,先暂时采用system来启动Gameplay服务器,后期采用docker进行管理 Gameplay 服务器
#if PLATFORM == PLATFORM_WIN
@@ -69,9 +69,7 @@ void LogicModule::OnReqPvpInstanceCreate(const socket_t sock, const int msg_id,
#if PLATFORM == PLATFORM_LINUX
cmd += " &";
#endif
- dout << "执行: " << cmd << std::endl;
system(cmd.c_str());
- dout << "执行命令结束" << std::endl;
}
} // namespace gameplay_manager::logic
\ No newline at end of file
diff --git a/src/node/ds_mgr/logic/manager_module.h b/src/node/ds_mgr/logic/manager_module.h
index 0b5d3bad..8b56eb0b 100644
--- a/src/node/ds_mgr/logic/manager_module.h
+++ b/src/node/ds_mgr/logic/manager_module.h
@@ -24,9 +24,9 @@ class ManagerModule : public IManagerModule {
protected:
// 创建实例
- void InstanceCreate(const string &instanceId, const string &key);
+ // void InstanceCreate(const string &instanceId, const string &key);
// 销毁实例
- void InstanceDestroy(const string &instanceId);
+ // void InstanceDestroy(const string &instanceId);
private:
IClassModule *m_class_;
diff --git a/src/node/game/logic/game_mgr_module.cc b/src/node/game/logic/game_mgr_module.cc
index c5d02559..41e5dfcc 100644
--- a/src/node/game/logic/game_mgr_module.cc
+++ b/src/node/game/logic/game_mgr_module.cc
@@ -86,7 +86,7 @@ bool GameMgrModule::DoGamePlayerQuit(const Guid &player) {
if (id != -1) {
auto iter = games_.find(id);
if (iter == games_.end()) {
- dout << "No this gameplay: " << id << std::endl;
+ // dout << "No this gameplay: " << id << std::endl;
}
auto gameplay = games_[id];
if (gameplay != nullptr) {
@@ -96,10 +96,10 @@ bool GameMgrModule::DoGamePlayerQuit(const Guid &player) {
return GameDestroy(id);
}
} else {
- dout << "This player not in game." << std::endl;
+ // dout << "This player not in game." << std::endl;
}
} else {
- dout << "This player not in game." << std::endl;
+ // dout << "This player not in game." << std::endl;
}
return false;
}
@@ -134,7 +134,7 @@ void GameMgrModule::OnRecv(const socket_t sock, const int msg_id, const char *ms
auto iter = games_.find(group_id);
if (iter == games_.end()) {
- dout << "no this group: " << group_id << " msg_id: " << msg_id << std::endl;
+ // dout << "no this group: " << group_id << " msg_id: " << msg_id << std::endl;
return;
}
@@ -145,11 +145,11 @@ void GameMgrModule::OnRecv(const socket_t sock, const int msg_id, const char *ms
GAME_MGR_RECEIVE_FUNCTOR *pFunc = ptr.get();
pFunc->operator()(clientID, msg_id, xMsg.msg_data());
} else {
- dout << "no this callback! msg_id: " << msg_id << std::endl;
+ // dout << "no this callback! msg_id: " << msg_id << std::endl;
}
} else {
- dout << "no this group: " << group_id << " msg_id: " << msg_id << std::endl;
+ // dout << "no this group: " << group_id << " msg_id: " << msg_id << std::endl;
}
}
diff --git a/src/node/game/logic/i_game.h b/src/node/game/logic/i_game.h
index c0ee2b42..fe43ac3c 100644
--- a/src/node/game/logic/i_game.h
+++ b/src/node/game/logic/i_game.h
@@ -46,14 +46,14 @@ class IGame {
}
inline void DoAwake() {
- dout << "Game Play Parent Awake!\n";
+ // dout << "Game Play Parent Awake!\n";
MsgBind(GameBaseRPC::REQ_GAME_JOIN, this, &IGame::OnReqGameJoin);
Awake();
};
inline void DoStart() {
status = RUNNING;
- dout << "Game Play Parent Start!\n";
+ // dout << "Game Play Parent Start!\n";
// 初始化完毕后,通过告诉房间实现加入
// manager->m_room_->GamePlayPrepared(id, "game", "", 0);
Start();
@@ -67,7 +67,7 @@ class IGame {
};
void OnReqGameJoin(const Guid &clientID, const int msg_id, const std::string &data) {
- dout << "Req Game Join\n";
+ // dout << "Req Game Join\n";
DoPlayerJoin(clientID);
}
@@ -82,13 +82,11 @@ class IGame {
// 判断是否重复加入
// if (-1 != manager->m_player_manager_->GetPlayerGameplayID(player)) {
- // dout << "重复加入!\n";
// return;
//}
// 判断玩家数量是否超限
if (onlinePlayerCount > 5) {
- dout << "重复加入!\n";
return;
}
@@ -158,13 +156,13 @@ class IGame {
void DoPlayerQuit(const Guid &p) {
auto iter = base_players.find(p);
if (iter == base_players.end()) {
- dout << "Error not found this player\n";
+ // dout << "Error not found this player\n";
return;
}
auto &player = iter->second;
player.isOnline = false;
onlinePlayerCount--;
- dout << "Online Count: " << onlinePlayerCount << std::endl;
+ // dout << "Online Count: " << onlinePlayerCount << std::endl;
PlayerQuit(player.guid);
}
@@ -237,7 +235,7 @@ class IGame {
inline void SetPlayerActive(const Guid &player, bool isActive) {
auto iter = base_players.find(player);
if (iter == base_players.end()) {
- dout << "Not found this player\n";
+ // dout << "Not found this player\n";
return;
}
iter->second.isActive = isActive;
diff --git a/src/node/master/logic/logic_module.cc b/src/node/master/logic/logic_module.cc
index 56806161..a72718b7 100644
--- a/src/node/master/logic/logic_module.cc
+++ b/src/node/master/logic/logic_module.cc
@@ -19,6 +19,7 @@ bool LogicModule::AfterStart() {
m_net_->AddReceiveCallBack(rpc::IdNReqMinWorkloadNodeInfo, this, &LogicModule::OnNReqMinWorkNodeInfo);
m_net_->AddReceiveCallBack(rpc::IdNNtfNodeMsgForward, this, &LogicModule::OnNNtfNodeMsgForward);
m_net_->AddReceiveCallBack(rpc::IdNReqAllNodesInfo, this, &LogicModule::OnNReqAllNodesInfo);
+ m_net_->AddReceiveCallBack(rpc::IdNReqReload, this, &LogicModule::OnNReqReload);
m_http_server_ = pm_->FindModule<::IHttpServerModule>();
@@ -282,4 +283,25 @@ bool LogicModule::OnGetNodeList(std::shared_ptr req) {
return m_http_server_->ResponseMsg(req, statusRoot.dump(), WebStatus::WEB_OK);
}
+void LogicModule::OnNReqReload(const socket_t sock, const int msg_id, const char *msg, const uint32_t len) {
+ rpc::MsgBase msg_base;
+ if (!msg_base.ParseFromArray(msg, len)) {
+ LOG_ERROR("ParseFromArray: is error, the msg len %v", len);
+ return;
+ }
+
+ std::cout << "Master reloading....\n";
+ reqid_t req_id = msg_base.req_id();
+ rpc::NAckReload ack;
+
+ for (auto s : node_map_) {
+ LOG_INFO("Master Req reload: [%v]", s.second.info->id());
+ m_net_->SendPBToNode(rpc::IdNReqReload, ack, s.second.fd);
+ }
+
+ m_net_->SendPBToNode(rpc::IdNAckReload, ack, sock, 0, req_id);
+
+}
+
} // namespace master::logic
+
diff --git a/src/node/master/logic/logic_module.h b/src/node/master/logic/logic_module.h
index 923946e4..e63a11ae 100644
--- a/src/node/master/logic/logic_module.h
+++ b/src/node/master/logic/logic_module.h
@@ -25,6 +25,7 @@ class LogicModule : public ILogicModule {
void OnNReqMinWorkNodeInfo(const socket_t sock, const int msg_id, const char *msg, const uint32_t len);
void OnNNtfNodeMsgForward(const socket_t sock, const int msg_id, const char *msg, const uint32_t len);
void OnNReqAllNodesInfo(const socket_t sock, const int msg_id, const char *msg, const uint32_t len);
+ void OnNReqReload(const socket_t sock, const int msg_id, const char *msg, const uint32_t len);
int GetLoadBanlanceNode(int type);
@@ -57,4 +58,4 @@ class LogicModule : public ILogicModule {
time_t last_report_time_;
};
-} // namespace master::logic
\ No newline at end of file
+} // namespace master::logic
diff --git a/src/node/proxy/logic/logic_module.cc b/src/node/proxy/logic/logic_module.cc
index 1f98ff92..38347a67 100644
--- a/src/node/proxy/logic/logic_module.cc
+++ b/src/node/proxy/logic/logic_module.cc
@@ -33,6 +33,7 @@ bool LogicModule::AfterStart() {
m_ws_->AddReceiveCallBack(this, &LogicModule::OnOtherMessage);
m_ws_->AddReceiveCallBack(rpc::IdReqPlayerEnter, this, &LogicModule::OnReqPlayerEnter);
m_ws_->AddReceiveCallBack(rpc::IdReqPlayerLeave, this, &LogicModule::OnReqPlayerLeave);
+ m_ws_->AddReceiveCallBack(rpc::IdReqHeartBeat, this, &LogicModule::OnHeartbeat);
// Lobby
m_net_client_->AddReceiveCallBack(rpc::ST_PLAYER, this, &LogicModule::OnRecivedPlayerNodeMsg);
diff --git a/src/proto/n_master.proto b/src/proto/n_master.proto
index 2c8c79fd..1b1d49e9 100644
--- a/src/proto/n_master.proto
+++ b/src/proto/n_master.proto
@@ -1,5 +1,6 @@
// Desc: Master RPC 500 ~ 1000
syntax = "proto3";
+import "n_node.proto";
package rpc;
enum NodeState {
@@ -107,4 +108,20 @@ message NReqAllNodesInfo { // msg_id=512;
message NAckAllNodesInfo { // msg_id=513;
repeated Node node_list = 1;
+}
+
+enum ReloadType {
+ ReloadTypeAll = 0;
+ ReloadNodeConfig = 1;
+ ReloadExcelConfig = 2;
+ ReloadNodeScript = 3;
+}
+
+message NReqReload { // msg_id=514;
+ ReloadType type = 1;
+}
+
+message NAckReload { // msg_id=515;
+ NErrorCode code = 1;
+ ReloadType type = 2;
}
\ No newline at end of file
diff --git a/src/proto/n_node.proto b/src/proto/n_node.proto
index 15e12076..e45bf185 100644
--- a/src/proto/n_node.proto
+++ b/src/proto/n_node.proto
@@ -19,3 +19,17 @@ enum NErrorCode {
NErrCommonSucc = 0;
NErrCommonFaild = 1;
}
+
+message NReqExecuteLua { // msg_id=10;
+ int32 node_id = 1;
+ int32 type = 2;
+ string script = 3;
+}
+
+message NAckExecuteLua { // msg_id=11;
+ NErrorCode code = 1;
+ int32 node_id = 2;
+ int32 type = 3;
+ string output = 4;
+}
+
diff --git a/src/pycli/logic.py b/src/pycli/logic.py
index efd32084..f3d75c2a 100644
--- a/src/pycli/logic.py
+++ b/src/pycli/logic.py
@@ -1,6 +1,14 @@
from protocol import *
+import threading
+import time
Instance = {}
+IsExit = False
+
+def LogicExit():
+ print("Logic exit")
+ global IsExit;
+ IsExit = True
def RegisterMsg(instance):
global Instance
@@ -8,10 +16,14 @@ def RegisterMsg(instance):
if ('callback' not in instance):
instance['callback'] = {}
instance['callback'][IdAckConnectProxy] = HandleAckConnectProxy
+ instance['callback'][IdAckHeartBeat] = HandleAckHeartBeat
instance['callback'][IdAckPlayerEnter] = HandleAckPlayerEnter
instance['callback'][IdAckPlayerData] = HandleAckPlayerData
Instance = instance
-
+ Instance['is_connected'] = True
+ Instance['last_heartbeat_time'] = 0
+ t1 = threading.Thread(target=LogicLoop)
+ t1.start()
def SendMsg(msg_id, pb_msg):
data = Encode(msg_id, pb_msg.SerializeToString())
@@ -39,3 +51,24 @@ def HandleAckPlayerData(msg_id, msg):
def HandleOffline(msg_id, msg):
print("Player offline")
+
+def HandleAckHeartBeat(msg_id, msg):
+ ack = AckHeartBeat()
+ ack.ParseFromString(msg)
+ data = MessageToJson(ack)
+ print("Get the heartbeat info: \n", data)
+ index = 0
+
+def LogicLoop():
+ global Instance
+ index = 0
+ while IsExit == False:
+ time.sleep(0.1)
+ now_time = int(time.time())
+ if Instance['is_connected'] == True:
+ if(now_time - Instance['last_heartbeat_time'] > 5):
+ Instance['last_heartbeat_time'] = now_time
+ req = ReqHeartBeat()
+ req.index = index
+ SendMsg(IdReqHeartBeat, req)
+ index += 1
diff --git a/src/pycli/main.py b/src/pycli/main.py
index ab4d2c56..c9fdb428 100644
--- a/src/pycli/main.py
+++ b/src/pycli/main.py
@@ -21,6 +21,7 @@
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) Chrome/89.0.4389.82'
}
+
def login(account, password):
try:
login_data = {
@@ -57,7 +58,6 @@ def HandleMsg(data):
Instance['callback'][msg_id](msg_id, msg)
def OnWsRecv(ws, message):
- print("Message:", message)
HandleMsg(message)
def OnWsError(ws, error):
@@ -74,7 +74,7 @@ def OnWsOpen(ws):
if __name__ == '__main__':
# login
print("Begin pycli")
- err, rsp = login("pycli", "password")
+ err, rsp = login("pycli_1", "password")
if (err):
print("Error...")
exit()
@@ -97,4 +97,5 @@ def OnWsOpen(ws):
rel.signal(2, rel.abort) # Keyboard Interrupt
rel.dispatch()
- print("run")
+ LogicExit()
+ print("\nExited!")
diff --git a/src/squick/core/base.cc b/src/squick/core/base.cc
index 7cf368fd..770de029 100644
--- a/src/squick/core/base.cc
+++ b/src/squick/core/base.cc
@@ -3,6 +3,13 @@
std::atomic is_squick_main_thread_sleep = true;
+std::atomic squick_reload_state = 0;
+
void SetSquickMainThreadSleep(bool is_sleep) { is_squick_main_thread_sleep = is_sleep; }
-bool IsSquickMainThreadSleep() { return is_squick_main_thread_sleep; }
\ No newline at end of file
+bool IsSquickMainThreadSleep() { return is_squick_main_thread_sleep; }
+
+
+void SetSquickReloadState(int state) { squick_reload_state = state; }
+
+int GetSquickReloadState() { return squick_reload_state; }
\ No newline at end of file
diff --git a/src/squick/core/base.h b/src/squick/core/base.h
index 7adc1d0e..e051b4d8 100644
--- a/src/squick/core/base.h
+++ b/src/squick/core/base.h
@@ -25,16 +25,8 @@
#define SQUICK_SSL_PRIVATE_KEY "../config/ssl/private-key.pem"
#endif
-//
-// #undef SQUICK_DEV
-#ifdef SQUICK_DEV
#define dout std::cout << "SQUICK_DEV LOG:" << __FILE__ << ":" << __LINE__ << " "
#define eout std::cout << "ERROR: "
-#else
-// Release版本时可以将 dout 打印给注释掉
-#define stuff
-#define dout / stuff /
-#endif
#define SQUICK_DPRINT(x) std::cout << termcolor::cyan << __FILE__ << ":" << __LINE__ << ":" << x << "\n" << termcolor::reset;
#define SQUICK_PRINT(x) std::cout << termcolor::cyan << x << termcolor::reset << std::endl;
@@ -44,6 +36,9 @@
SQUICK_EXPORT void SetSquickMainThreadSleep(bool is_sleep);
SQUICK_EXPORT bool IsSquickMainThreadSleep();
+SQUICK_EXPORT void SetSquickReloadState(int state);
+SQUICK_EXPORT int GetSquickReloadState();
+
//
#define DEFAULT_MASTER_ID 1 // master_id=1, cannot set
diff --git a/src/squick/core/i_module.h b/src/squick/core/i_module.h
index f4d51b81..a25de1d4 100644
--- a/src/squick/core/i_module.h
+++ b/src/squick/core/i_module.h
@@ -30,6 +30,8 @@ class IModule {
virtual bool OnReloadPlugin() { return true; }
+ virtual bool Reload(int type) { return true; }
+
virtual IPluginManager *GetPluginManager() const { return pm_; }
std::string name_;
diff --git a/src/squick/core/i_plugin.h b/src/squick/core/i_plugin.h
index 7603b10d..230e60bc 100644
--- a/src/squick/core/i_plugin.h
+++ b/src/squick/core/i_plugin.h
@@ -139,6 +139,16 @@ class IPlugin : public IModule {
return true;
}
+ virtual bool Reload(int type) {
+ for (const auto &it : mModules) {
+ IModule *pModule = it.second;
+ pm_->SetCurrentModule(pModule);
+ pModule->Reload(type);
+ }
+
+ return true;
+ }
+
virtual bool BeforeDestroy() {
for (const auto &it : mModules) {
IModule *pModule = it.second;
diff --git a/src/squick/core/i_plugin_manager.h b/src/squick/core/i_plugin_manager.h
index 4ecb4d99..55fc468d 100644
--- a/src/squick/core/i_plugin_manager.h
+++ b/src/squick/core/i_plugin_manager.h
@@ -63,6 +63,8 @@ class IPluginManager {
virtual bool OnReloadPlugin() { return true; }
+ virtual bool Reload(int type) { return true; }
+
/////////////////////
template T *FindModule() {
diff --git a/src/squick/core/plugin_manager.cc b/src/squick/core/plugin_manager.cc
index e273d3a4..f478d360 100644
--- a/src/squick/core/plugin_manager.cc
+++ b/src/squick/core/plugin_manager.cc
@@ -450,6 +450,16 @@ bool PluginManager::Finalize() {
return true;
}
+
+bool PluginManager::Reload(int type) {
+ PluginInstanceMap::iterator itInstance = mPluginInstanceMap.begin();
+ for (; itInstance != mPluginInstanceMap.end(); itInstance++) {
+ SetCurrentPlugin(itInstance->second);
+ itInstance->second->Reload(type);
+ }
+ return true;
+}
+
bool PluginManager::LoadPluginLibrary(const std::string &pluginDLLName) {
PluginLibMap::iterator it = mPluginLibMap.find(pluginDLLName);
if (it == mPluginLibMap.end()) {
diff --git a/src/squick/core/plugin_manager.h b/src/squick/core/plugin_manager.h
index 88ea3116..379de1d7 100644
--- a/src/squick/core/plugin_manager.h
+++ b/src/squick/core/plugin_manager.h
@@ -33,6 +33,8 @@ class PluginManager : public IPluginManager {
virtual bool Finalize() override;
+ virtual bool Reload(int type) override;
+
//////////////////////////////////////////////////////////////////////////
virtual void Registered(IPlugin *pPlugin) override;
diff --git a/src/squick/core/plugin_server.cc b/src/squick/core/plugin_server.cc
index 1d2d54ad..1c2252b0 100644
--- a/src/squick/core/plugin_server.cc
+++ b/src/squick/core/plugin_server.cc
@@ -45,6 +45,10 @@ void PluginServer::Start() {
pm_->ReadyUpdate();
}
+void PluginServer::Reload(int type) {
+ pm_->Reload(type);
+}
+
void PluginServer::Final() {
pm_->BeforeDestroy();
pm_->Destroy();
diff --git a/src/squick/core/plugin_server.h b/src/squick/core/plugin_server.h
index a9f89b5c..ea5ae230 100644
--- a/src/squick/core/plugin_server.h
+++ b/src/squick/core/plugin_server.h
@@ -35,6 +35,7 @@ class PluginServer {
void Start();
void Update();
void Final();
+ void Reload(int type);
void SetBasicWareLoader(std::function fun);
void SetMidWareLoader(std::function fun);
diff --git a/src/squick/plugin/lua/lua_script_module.cc b/src/squick/plugin/lua/lua_script_module.cc
index 856d47ae..0eb0aa41 100644
--- a/src/squick/plugin/lua/lua_script_module.cc
+++ b/src/squick/plugin/lua/lua_script_module.cc
@@ -68,6 +68,13 @@ bool LuaScriptModule::Start() {
return true;
}
+
+bool LuaScriptModule::Reload(int type) {
+ LOG_INFO("Lua module reloaded, reload type %v", type);
+ TRY_RUN_GLOBAL_SCRIPT_FUN0("HotReload");
+ return true;
+}
+
// 用于Lua 初始化
bool LuaScriptModule::AfterStart() {
TRY_RUN_GLOBAL_SCRIPT_FUN0("AfterStart");
@@ -102,6 +109,20 @@ bool LuaScriptModule::BeforeDestroy() {
return true;
}
+// 用于Lua 初始化
+string LuaScriptModule::ExecuteLua(const std::string script, bool &is_error) {
+ try {
+ LuaIntf::LuaRef func(mLuaContext, "ExecuteLua");
+ auto output = func.call(script);
+ is_error = false;
+ return output;
+ } catch (LuaIntf::LuaException & e) {
+ is_error = true;
+ return e.what();
+ }
+ return "";
+}
+
LuaIntf::LuaContext &LuaScriptModule::GetLuaEnv() { return this->mLuaContext; }
Guid LuaScriptModule::CreateObject(const Guid &self, const int sceneID, const int groupID, const std::string &className, const std::string &objectIndex,
diff --git a/src/squick/plugin/lua/lua_script_module.h b/src/squick/plugin/lua/lua_script_module.h
index 10a75446..9a815bd6 100644
--- a/src/squick/plugin/lua/lua_script_module.h
+++ b/src/squick/plugin/lua/lua_script_module.h
@@ -26,6 +26,7 @@
class ILuaScriptModule : public IModule {
public:
+ virtual std::string ExecuteLua(const std::string script, bool &is_error) = 0;
};
class LuaScriptModule : public ILuaScriptModule {
@@ -42,6 +43,7 @@ class LuaScriptModule : public ILuaScriptModule {
virtual bool Awake();
virtual bool Start();
+ virtual bool Reload(int type) override;
virtual bool Destroy();
virtual bool ReadyUpdate();
virtual bool Update();
@@ -50,6 +52,7 @@ class LuaScriptModule : public ILuaScriptModule {
virtual bool BeforeDestroy();
virtual LuaIntf::LuaContext &GetLuaEnv();
+ virtual std::string ExecuteLua(const std::string script, bool &is_error);
protected:
// FOR KERNEL MODULE
diff --git a/src/squick/plugin/net/http_client.cc b/src/squick/plugin/net/http_client.cc
index 8fba27c0..099514fe 100644
--- a/src/squick/plugin/net/http_client.cc
+++ b/src/squick/plugin/net/http_client.cc
@@ -332,7 +332,7 @@ Awaitable HttpClient::CoPost(const std::string &url, con
void HttpClient::CoroutineBinder(Awaitable *awaitble) {
if (awaitble == nullptr) {
- dout << "awaitble is nullptr\n";
+ // LOG_ERROR("awaitble is nullptr", "");
return;
}
reqid_t req_id = awaitble->data_.req_id;
@@ -340,23 +340,21 @@ void HttpClient::CoroutineBinder(Awaitable *awaitble) {
if (iter == co_awaitbles_.end()) {
co_awaitbles_[req_id] = awaitble;
} else {
- dout << "CoroutineBinder: same req id in a map, req id: " << req_id << " address: " << awaitble->coro_handle_.address() << std::endl;
+ // LOG_ERROR("CoroutineBinder: same req id in a map, req id: %v, address %v ", req_id, awaitble->coro_handle_.address());
}
}
void HttpClient::CoroutineResponseHandler(const Guid id, const int state_code, const std::string &strRespData, const std::string &strMemoData) {
- dout << "CoroutineResponseHandler: \n";
reqid_t req_id = id.nData64;
auto iter = co_awaitbles_.find(req_id);
if (iter == co_awaitbles_.end()) {
- dout << "CoroutineBinder: Not find req id in a map, req id: " << req_id << std::endl;
+ // LOG_ERROR("CoroutineBinder: Not find req id in a map, req id: %v" << req_id);
return;
}
auto awaitble = iter->second;
awaitble->data_.error = 0;
awaitble->data_.content = strRespData;
awaitble->data_.state_code = state_code;
- dout << "CoroutineResponseHandler: coroutineid: " << awaitble->coro_handle_.address() << endl;
// resume coroutine
if (!awaitble->coro_handle_.done()) {
diff --git a/src/squick/plugin/net/http_server.cc b/src/squick/plugin/net/http_server.cc
index b2ec8d2c..a5ff20a9 100644
--- a/src/squick/plugin/net/http_server.cc
+++ b/src/squick/plugin/net/http_server.cc
@@ -173,7 +173,7 @@ void HttpServer::listener_cb(struct evhttp_request *req, void *arg) {
return;
} else {
pNet->mxHttpRequestPool.push_back(pRequest);
- pNet->ResponseMsg(pRequest, "Filter error", xWebStatus);
+ pNet->ResponseMsg(pRequest, "", xWebStatus);
return;
}
} catch (std::exception &e) {
diff --git a/src/squick/plugin/net/http_server_module.cc b/src/squick/plugin/net/http_server_module.cc
index 5a49dff3..e3f06d66 100644
--- a/src/squick/plugin/net/http_server_module.cc
+++ b/src/squick/plugin/net/http_server_module.cc
@@ -37,9 +37,6 @@ int HttpServerModule::FixCoroutines(time_t now_time) {
auto co = *now_iter;
if (co.GetHandle().done()) {
co.GetHandle().destroy();
-#ifdef SQUICK_DEV
- dout << "Destoy coroutine: " << co.GetHandle().address() << endl;
-#endif
coroutines_.erase(now_iter);
num++;
continue;
@@ -47,7 +44,7 @@ int HttpServerModule::FixCoroutines(time_t now_time) {
if (now_time - co.GetStartTime() > HTTP_SERVER_COROTINE_MAX_SURVIVAL_TIME) {
#ifdef SQUICK_DEV
- dout << " This corotine has time out: " << co.GetHandle().address() << std::endl;
+ LOG_ERROR("This corotine has time out: %v", co.GetHandle().address());
#endif
// do not destroy
if (!co.GetHandle().done()) {
@@ -85,13 +82,10 @@ bool HttpServerModule::OnReceiveNetPack(std::shared_ptr req) {
auto co = pFunc->operator()(req);
coroutines_.push_back(co);
-#ifdef SQUICK_DEV
- dout << "Create a new coroutine: " << co.GetHandle().address() << endl;
-#endif
// to run this coroutine
co.GetHandle().resume();
} catch (const std::exception &e) {
- dout << "Http quest error: " << e.what() << std::endl;
+ LOG_ERROR("Http quest error: %v", e.what());
ResponseMsg(req, "unknow error", WebStatus::WEB_INTER_ERROR);
}
return true;
@@ -108,7 +102,7 @@ bool HttpServerModule::OnReceiveNetPack(std::shared_ptr req) {
try {
pFunc->operator()(req);
} catch (const std::exception &e) {
- dout << "Http quest error: " << e.what() << std::endl;
+ LOG_ERROR("Http quest error: %v", e.what());
ResponseMsg(req, "unknow error", WebStatus::WEB_INTER_ERROR);
}
return true;
diff --git a/src/squick/plugin/net/net.cc b/src/squick/plugin/net/net.cc
index 52b0252d..ccab17f1 100644
--- a/src/squick/plugin/net/net.cc
+++ b/src/squick/plugin/net/net.cc
@@ -24,7 +24,6 @@ TO
#define SQUICK_BUFFER_MAX_READ 1048576
void Net::event_fatal_cb(int err) {
- // dout << "event_fatal_cb: " << err << std::endl;
}
void Net::conn_writecb(struct bufferevent *bev, void *user_data) {
diff --git a/src/squick/plugin/net/net_module.cc b/src/squick/plugin/net/net_module.cc
index 6bc8b97a..b29d651d 100644
--- a/src/squick/plugin/net/net_module.cc
+++ b/src/squick/plugin/net/net_module.cc
@@ -182,9 +182,6 @@ int NetModule::FixCoroutines(time_t now_time) {
auto co = *now_iter;
if (co.GetHandle().done()) {
co.GetHandle().destroy();
-#ifdef SQUICK_DEV
- dout << "Destoy coroutine: " << co.GetHandle().address() << endl;
-#endif
coroutines_.erase(now_iter);
num++;
continue;
@@ -192,7 +189,7 @@ int NetModule::FixCoroutines(time_t now_time) {
if (now_time - co.GetStartTime() > NET_COROTINE_MAX_SURVIVAL_TIME) {
#ifdef SQUICK_DEV
- dout << " This corotine has time out: " << co.GetHandle().address() << std::endl;
+ LOG_WARN(" This corotine has time out: %v", co.GetHandle().address());
#endif
// do not destroy
if (!co.GetHandle().done()) {
diff --git a/src/squick/plugin/node/node_module.cc b/src/squick/plugin/node/node_module.cc
index 9ce382b9..d173f4fd 100644
--- a/src/squick/plugin/node/node_module.cc
+++ b/src/squick/plugin/node/node_module.cc
@@ -1,5 +1,6 @@
#include "node_module.h"
+#include
NodeModule::NodeModule(IPluginManager *p) {
pm_ = p;
@@ -104,6 +105,7 @@ rpc::NodeType NodeModule::StringNodeTypeToEnum(const std::string &type) {
bool NodeModule::Listen() {
m_net_->AddReceiveCallBack(this, &NodeModule::InvalidMessage);
m_net_->AddEventCallBack(this, &NodeModule::OnServerSocketEvent);
+ m_net_->AddReceiveCallBack(rpc::IdNReqExecuteLua, this, &NodeModule::OnNReqExecuteLua);
node_info_.info->set_id(pm_->GetArg("id=", ARG_DEFAULT_ID));
node_info_.info->set_type(pm_->GetAppType());
@@ -135,6 +137,9 @@ bool NodeModule::AddSubscribeNode(const vector &types) {
m_net_client_->AddReceiveCallBack(rpc::ST_MASTER, rpc::IdNNtfNodeAdd, this, &NodeModule::OnNNtfNodeAdd);
m_net_client_->AddReceiveCallBack(rpc::ST_MASTER, rpc::IdNNtfNodeRemove, this, &NodeModule::OnNNtfNodeRemove);
m_net_client_->AddReceiveCallBack(rpc::ST_MASTER, rpc::IdNAckNodeRegister, this, &NodeModule::OnNAckNodeRegister);
+ m_net_client_->AddReceiveCallBack(rpc::ST_MASTER, rpc::IdNReqReload, this, &NodeModule::OnNReqReload);
+ m_net_client_->AddReceiveCallBack(rpc::ST_BACKSTAGE, rpc::IdNReqExecuteLua, this, &NodeModule::OnNReqExecuteLua);
+
bool ret = false;
node_info_.listen_types = types;
ConnectData s;
@@ -287,9 +292,59 @@ bool NodeModule::AddNodes(const google::protobuf::RepeatedPtrField &l
return true;
}
+// Reload config or lua script
+void NodeModule::OnNReqReload(const socket_t sock, const int msg_id, const char *msg, const uint32_t len) {
+ uint64_t uid;
+ rpc::NReqReload req;
+ if (!m_net_->ReceivePB(msg_id, msg, len, req, uid)) {
+ return;
+ }
+
+ LOG_INFO("Reload type: %v", (int)req.type());
+ SetSquickReloadState(1);
+}
+
+void NodeModule::OnNReqExecuteLua(const socket_t sock, const int msg_id, const char *msg, const uint32_t len) {
+ uint64_t uid;
+ rpc::NReqExecuteLua req;
+ rpc::NAckExecuteLua ack;
+
+ rpc::MsgBase msg_base;
+ if (!msg_base.ParseFromArray(msg, len)) {
+ LOG_ERROR("ParseFromArray: is error, the msg len %v", len);
+ return;
+ }
+ reqid_t req_id = msg_base.req_id();
+
+ if (!req.ParseFromString(msg_base.msg_data())) {
+ LOG_ERROR("ParseFromString: is error, the msg len %v", len);
+ }
+
+ ILuaScriptModule *m_lua = pm_->FindModule();
+ bool is_error = false;
+ if (m_lua) {
+ ack.set_output(m_lua->ExecuteLua(req.script(), is_error));
+ if (is_error)
+ {
+ ack.set_code(rpc::NErrorCode::NErrCommonFaild);
+ }
+ else {
+ ack.set_code(rpc::NErrorCode::NErrCommonSucc);
+ }
+ }
+ else {
+ LOG_ERROR("Find the lua script module is null", "");
+ ack.set_code(rpc::NErrorCode::NErrCommonFaild);
+ }
+
+ ack.set_node_id(req.node_id());
+ ack.set_type(req.type());
+ m_net_->SendPBToNode(rpc::IdNAckExecuteLua, ack, sock, 0, req_id);
+}
+
// Add node ntf
void NodeModule::OnNNtfNodeRemove(const socket_t sock, const int msg_id, const char *msg, const uint32_t len) {}
bool NodeModule::RemoveNodes() { return true; }
-ServerInfo &NodeModule::GetNodeInfo() { return node_info_; }
\ No newline at end of file
+ServerInfo &NodeModule::GetNodeInfo() { return node_info_; }
diff --git a/src/squick/plugin/node/node_module.h b/src/squick/plugin/node/node_module.h
index c1a1a2ea..71f711b6 100644
--- a/src/squick/plugin/node/node_module.h
+++ b/src/squick/plugin/node/node_module.h
@@ -54,6 +54,11 @@ class NodeModule : public INodeModule {
void OnNNtfNodeRemove(const socket_t sock, const int msg_id, const char *msg, const uint32_t len);
bool RemoveNodes();
+ void OnNReqReload(const socket_t sock, const int msg_id, const char *msg, const uint32_t len);
+
+ // Run lua code
+ void OnNReqExecuteLua(const socket_t sock, const int msg_id, const char *msg, const uint32_t len);
+
public:
ILogModule *m_log_;
INetModule *m_net_;
diff --git a/src/tools/sqkcli/core/tester_module.cc b/src/tools/sqkcli/core/tester_module.cc
index f29d42d6..8a93d309 100644
--- a/src/tools/sqkcli/core/tester_module.cc
+++ b/src/tools/sqkcli/core/tester_module.cc
@@ -99,7 +99,6 @@ void TesterModule::TestProxyTransferSpeed_Ack(const socket_t sock, const int msg
}
void TesterModule::TReqConfig() {
- dout << "Okkkk\n";
rpc::TReqConfig test;
test.set_index(test_req_index_);
test.set_data(test_req_data_);
diff --git a/src/tools/sqkctl/excel/cpp_generator.h b/src/tools/sqkctl/excel/cpp_generator.h
index e9c5d816..64adb69f 100644
--- a/src/tools/sqkctl/excel/cpp_generator.h
+++ b/src/tools/sqkctl/excel/cpp_generator.h
@@ -173,10 +173,6 @@ class CPPGenerator : public IGenerator {
std::string strFileEnd = "\n}\n#endif";
fwrite(strFileEnd.c_str(), strFileEnd.length(), 1, hppWriter);
- /////////////////////////////////////////////////////
-
- /////////////////////////////////////////////////////
-
fclose(hppWriter);
return false;
diff --git a/src/tools/sqkctl/excel/cs_generator.h b/src/tools/sqkctl/excel/cs_generator.h
index c4129b9b..3ce9fa63 100644
--- a/src/tools/sqkctl/excel/cs_generator.h
+++ b/src/tools/sqkctl/excel/cs_generator.h
@@ -158,7 +158,6 @@ class CSGenerator : public IGenerator {
std::string strFileEnd = "\n}";
fwrite(strFileEnd.c_str(), strFileEnd.length(), 1, csWriter);
-
fclose(csWriter);
return false;
diff --git a/src/tools/sqkctl/excel/ini_generator.h b/src/tools/sqkctl/excel/ini_generator.h
index d53d48ef..782aa8bc 100644
--- a/src/tools/sqkctl/excel/ini_generator.h
+++ b/src/tools/sqkctl/excel/ini_generator.h
@@ -66,9 +66,7 @@ class IniGenerator : public IGenerator {
} else {
std::cout << "save for ini error!!!!!---> " << fileName << std::endl;
}
-
- if (!iniWriter)
- fclose(iniWriter);
+ fclose(iniWriter);
}
return false;
diff --git a/src/tools/sqkctl/excel/java_generator.h b/src/tools/sqkctl/excel/java_generator.h
index 983205e6..df5b8b2a 100644
--- a/src/tools/sqkctl/excel/java_generator.h
+++ b/src/tools/sqkctl/excel/java_generator.h
@@ -100,7 +100,6 @@ class JAVAGenerator : public IGenerator {
fwrite(strClassEnd.c_str(), strClassEnd.length(), 1, javaWriter);
}
-
fclose(javaWriter);
return false;
diff --git a/src/tools/sqkctl/excel/logic_class_generator.h b/src/tools/sqkctl/excel/logic_class_generator.h
index ce63c27c..7ae87842 100644
--- a/src/tools/sqkctl/excel/logic_class_generator.h
+++ b/src/tools/sqkctl/excel/logic_class_generator.h
@@ -51,6 +51,7 @@ class LogicClassGenerator : public IGenerator {
std::string strFileEnd = "";
fwrite(strFileEnd.c_str(), strFileEnd.length(), 1, iniWriter);
+ fclose(iniWriter);
return false;
}
diff --git a/src/tools/sqkctl/excel/lua_generator.h b/src/tools/sqkctl/excel/lua_generator.h
index 5676fab2..dd1c34db 100644
--- a/src/tools/sqkctl/excel/lua_generator.h
+++ b/src/tools/sqkctl/excel/lua_generator.h
@@ -144,7 +144,6 @@ class LuaGenerator : public IGenerator {
}
std::string strFileEnd = "\n}";
fwrite(strFileEnd.c_str(), strFileEnd.length(), 1, hppWriter);
-
fclose(hppWriter);
return false;
}
diff --git a/src/tools/sqkctl/excel/struct_generator.h b/src/tools/sqkctl/excel/struct_generator.h
index 476bbf51..58eb63a6 100644
--- a/src/tools/sqkctl/excel/struct_generator.h
+++ b/src/tools/sqkctl/excel/struct_generator.h
@@ -139,8 +139,7 @@ class StructGenerator : public IGenerator {
std::cout << "save for struct error!!!!!---> " << fileName << std::endl;
}
- if (!structWriter)
- fclose(structWriter);
+ fclose(structWriter);
}
return false;
diff --git a/src/tutorial/t6_rpc/rpc_module.cc b/src/tutorial/t6_rpc/rpc_module.cc
index 1d39a3dd..1985a790 100644
--- a/src/tutorial/t6_rpc/rpc_module.cc
+++ b/src/tutorial/t6_rpc/rpc_module.cc
@@ -4,7 +4,6 @@ namespace tutorial {
bool SimpleModule::Start() {
m_net_client_ = pm_->FindModule();
m_net_client_->AddReceiveCallBack(rpc::ST_GAME, 1123, this, &SimpleModule::OnRecivedMsg);
- dout << "RPC Start ...\n";
return true;
}
diff --git a/tools/common.sh b/tools/common.sh
index 9c27f601..ae287463 100755
--- a/tools/common.sh
+++ b/tools/common.sh
@@ -5,8 +5,22 @@
# Github: https://github.com/pwnsky/squick
# Description: Bash script source file
-build_version="Release"
-#build_mode="dev"
+# Build version
+if [ -z $SQUICK_BUILD_VERSION ];then
+ SQUICK_BUILD_VERSION="Debug"
+fi
+echo "build version: $SQUICK_BUILD_VERSION"
+
+# Build mode
+if [ -z $SQUICK_BUILD_MODE ];then
+ SQUICK_BUILD_MODE="dev"
+fi
+echo "build mode: $SQUICK_BUILD_MODE"
+
+build_version=$SQUICK_BUILD_VERSION
+#build_version="Release"
+
+build_mode=$SQUICK_BUILD_MODE
project_path=`pwd`/..
build_path="$project_path/cache"
sys=`uname -s`
@@ -65,8 +79,6 @@ function check_err()
if [[ $errno != 0 ]];then
log_error "Has terminated process, The error number: $errno"
exit $errno
- else
- log_info "No error"
fi
}
diff --git a/tools/proto2code.bat b/tools/proto2code.bat
index 6759e44b..7bc19f5c 100644
--- a/tools/proto2code.bat
+++ b/tools/proto2code.bat
@@ -25,10 +25,30 @@ python proto_enum_to_lua.py
python proto_to_lua_str.py
cd ..
-for %%f in (%proto_path%\*.proto) do %proto_bin% --csharp_out=%csharp_out_path% --proto_path=%proto_path% %%f
-for %%f in (%proto_path%\*.proto) do %proto_bin% --python_out=%python_out_path% --proto_path=%proto_path% %%f
+for %%f in (%proto_path%\*.proto) do (
+ %proto_bin% --csharp_out=%csharp_out_path% --proto_path=%proto_path% %%f
+ if %ERRORLEVEL% neq 0 (
+ pause
+ exit /b %ERRORLEVEL%
+ )
+)
+
+for %%f in (%proto_path%\*.proto) do (
+ %proto_bin% --python_out=%python_out_path% --proto_path=%proto_path% %%f
+ if %ERRORLEVEL% neq 0 (
+ pause
+ exit /b %ERRORLEVEL%
+ )
+)
+
rem windows dll于linux so有所区别,windows在需要声明导出函数,才能让其他dll或程序进行调用 参考 https://www.cnblogs.com/zhongpan/p/8378825.html
-for %%f in (%proto_path%\*.proto) do %proto_bin% --cpp_out=dllexport_decl="WIN_DLL_EXPORT":%cpp_out_path% --proto_path=%proto_path% %%f
+for %%f in (%proto_path%\*.proto) do (
+ %proto_bin% --cpp_out=dllexport_decl="WIN_DLL_EXPORT":%cpp_out_path% --proto_path=%proto_path% %%f
+ if %ERRORLEVEL% neq 0 (
+ pause
+ exit /b %ERRORLEVEL%
+ )
+)
rem 删除多余的proto
del /f /q /s %csharp_out_path%\N*.cs
diff --git a/tools/proto2code.sh b/tools/proto2code.sh
index 1030f1c0..8634f26d 100755
--- a/tools/proto2code.sh
+++ b/tools/proto2code.sh
@@ -27,6 +27,7 @@ check_err
python3 proto_enum_to_lua.py
check_err
python3 proto_to_lua_str.py
+check_err
cd ..
proto_files=$proto_path/*.proto
@@ -34,7 +35,9 @@ for f in $proto_files
do
echo $f
$proto_bin --cpp_out=$cpp_out_path --proto_path=$proto_path $f
+ check_err
$proto_bin --csharp_out=$csharp_out_path --proto_path=$proto_path $f
+ check_err
$proto_bin --python_out=$python_out_path --proto_path=$proto_path $f
check_err
done