Skip to content

Commit

Permalink
Merge pull request #59 from pwnsky/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
i0gan authored Oct 28, 2024
2 parents b1bc5ce + 6dd20b6 commit d6eb338
Show file tree
Hide file tree
Showing 372 changed files with 521 additions and 509 deletions.
5 changes: 2 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,8 @@ add_definitions(-D_X64 -D_CONSOLE -DSQUICK_DYNAMIC_PLUGIN -DSQUICK_ENABLE_SSL)
add_definitions(-DSQUICK_LOG_OPEN_STDOUT) # Log stdout print

add_subdirectory(src/struct)
add_subdirectory(src/squick)
add_subdirectory(src/node)
add_subdirectory(src/tutorial)
add_subdirectory(src/core)
add_subdirectory(src/plugin)


if( EXTRA STREQUAL "EXTRA" )
Expand Down
14 changes: 0 additions & 14 deletions script/benchmark.bat

This file was deleted.

26 changes: 0 additions & 26 deletions script/benchmark.sh

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions script/env.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
set SQUICK_RUN_ENV=ten
56 changes: 56 additions & 0 deletions script/gen_env_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#! /usr/bin/python3
import os
import collections
import sys

if len(sys.argv) < 2:
env='dev'
else:
env=sys.argv[1]

print('Gen env: ' + env)

tmpl_path = '../config/tmpl'
tmpl_value_path = '../config/tmpl/env'
cfg_path = '../config/node'

cfg_map = {}
conf_content = ''

def GetFileContent(path):
fd = open(path, 'r')
return fd.read()

for root, dirs, files in os.walk(tmpl_path):
for f in files:
if f.endswith('.json'):
print("json file: ", f)
cfg_map[f] = GetFileContent(tmpl_path + '/' + f)
elif f.endswith('.conf'):
print("conf file: ", f)
if f == env + '.conf':
conf_content = GetFileContent(tmpl_path + '/env/' + f)


# replace
if (len(conf_content) > 0):
conf_arr = conf_content.split('\n')
for conf_line in conf_arr:
conf = conf_line.split('=')
if len(conf) < 2:
continue
key = conf[0]
value = conf[1]
for k2 in cfg_map:
tmp = cfg_map[k2]
tmp = tmp.replace('{' + key + '}', value)
cfg_map[k2] = tmp
else:
print("Get " + env + " error")
exit(-1)

# save
for k in cfg_map:
fd = open(cfg_path + '/' + k, 'w')
fd.write(cfg_map[k])
fd.close()
22 changes: 0 additions & 22 deletions script/sqkcli.sh

This file was deleted.

3 changes: 3 additions & 0 deletions script/squick.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ rem Date : 2022-11-27
rem Github: https://github.com/pwnsky/squick
rem Description: Start all servers script

call env.bat
python gen_env_config.py %SQUICK_RUN_ENV%

cd ..\bin

start /b .\squick
6 changes: 6 additions & 0 deletions script/squick.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`pwd`/lib
# for macos
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:`pwd`

echo $SQUICK_MEMORY_CHECK
if [ "1" == "$SQUICK_MEMORY_CHECK" ];then
valgrind --leak-check=full ./squick $@
exit
fi

echo $SQUICK_ARGS
if [ -z $SQUICK_ARGS ];then
./squick $@
Expand Down
3 changes: 3 additions & 0 deletions script/start.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ rem Date : 2024-04-08
rem Github: https://github.com/pwnsky/squick
rem Description: Start all nodes

call env.bat
python gen_env_config.py %SQUICK_RUN_ENV%

cd ..\bin

start cmd /c " squick type=master id=1 area=0 ip=127.0.0.1 port=10001 web_port=50000"
Expand Down
12 changes: 0 additions & 12 deletions script/stop_benchmark.bat

This file was deleted.

12 changes: 0 additions & 12 deletions script/stop_benchmark.sh

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "platform.h"
#include <functional>
#include <list>
#include <squick/core/guid.h>
#include <core/guid.h>
#include <vector>

class IPlugin;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/squick/core/performance.h → src/core/performance.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include <iostream>
#include <squick/core/base.h>
#include <core/base.h>
#include <time.h>
class Performance {
private:
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "third_party/rapidxml/rapidxml_iterators.hpp"
#include "third_party/rapidxml/rapidxml_print.hpp"
#include "third_party/rapidxml/rapidxml_utils.hpp"
#include <squick/core/base.h>
#include <core/base.h>

PluginManager::PluginManager() : IPluginManager() {
appID = 0;
Expand All @@ -20,7 +20,7 @@ PluginManager::PluginManager() : IPluginManager() {
mGetFileContentFunctor = nullptr;

configPath = ".."; // 主要服务路径
configName = "config/plugin/plugin.xml"; // 默认插件加载路径
configName = "config/plugin.xml"; // 默认插件加载路径
}

PluginManager::~PluginManager() {}
Expand Down Expand Up @@ -64,7 +64,7 @@ bool PluginManager::LoadPluginConfig() {
rapidxml::xml_node<> *pRoot = xDoc.first_node();
if (pRoot == nullptr) {
SQUICK_PRINT("Cannot load plugin config from :" + strFilePath);
SQUICK_PRINT("Please check your working directory, make sure config file in the [../config/plugin/] directory.");
SQUICK_PRINT("Please check your working directory, make sure config file in the [../config/] directory.");
return false;
}
rapidxml::xml_node<> *pAppNameNode = pRoot->first_node(appName.c_str());
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "plugin_server.h"
#include <squick/core/base.h>
#include <squick/core/exception.h>
#include <core/base.h>
#include <core/exception.h>
#include <algorithm>

PluginServer::PluginServer(const std::string &strArgv) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 3 additions & 2 deletions src/main.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <iostream>
#include <squick/core/base.h>
#include <squick/core/plugin_server.h>
#include <core/base.h>
#include <core/plugin_server.h>
#include <struct/struct.h>

#if PLATFORM == PLATFORM_WIN
Expand Down Expand Up @@ -139,6 +139,7 @@ int main(int argc, char *argv[]) {
SetConsoleCtrlHandler(HandlerRoutine, TRUE);
#else
signal(SIGINT, SquickExit);
signal(SIGTERM, SquickExit);
#endif

for (auto item : serverList) {
Expand Down
6 changes: 6 additions & 0 deletions src/plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
add_subdirectory(core)
add_subdirectory(node)

if( MODE STREQUAL "dev" )
add_subdirectory(tutorial)
endif()
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "actor.h"
#include <squick/core/i_plugin_manager.h>
#include <core/i_plugin_manager.h>

Actor::Actor(const Guid id, IActorModule *pModule) {
this->id = id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
#include "i_actor_module.h"
#include "i_component_module.h"
#include <map>
#include <squick/core/guid.h>
#include <squick/core/map_ex.h>
#include <squick/core/platform.h>
#include <squick/core/queue.h>
#include <core/guid.h>
#include <core/map_ex.h>
#include <core/platform.h>
#include <core/queue.h>
#include <string>

class Actor : public IActor {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#include <queue>
#include <string>

#include <squick/core/queue.h>
#include <squick/plugin/thread/export.h>
#include <core/queue.h>
#include <plugin/core/thread/export.h>

#include "actor.h"
#include "i_actor_module.h"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
#include "i_component_module.h"
#include <squick/core/i_module.h>
#include <core/i_module.h>

class IActorModule : public IModule {
public:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#pragma once
#include <memory>
#include <squick/core/guid.h>
#include <squick/core/i_module.h>
#include <squick/core/memory_counter.h>
#include <squick/core/platform.h>
#include <core/guid.h>
#include <core/i_module.h>
#include <core/memory_counter.h>
#include <core/platform.h>

class ActorMessage;
class IComponent;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "plugin.h"
#include "actor_module.h"
#include <squick/core/i_module.h>
#include <core/i_module.h>

SQUICK_EXPORT void SquickPluginLoad(IPluginManager *pm){CREATE_PLUGIN(pm, ActorPlugin)};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

#include <squick/core/i_plugin.h>
#include <squick/core/i_plugin_manager.h>
#include <core/i_plugin.h>
#include <core/i_plugin_manager.h>

//////////////////////////////////////////////////////////////////////////
class ActorPlugin : public IPlugin {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
#include "i_element_module.h"
#include <iostream>
#include <map>
#include <squick/core/data_list.h>
#include <squick/core/i_plugin_manager.h>
#include <squick/core/list.h>
#include <squick/core/map.h>
#include <squick/core/property_manager.h>
#include <squick/core/record.h>
#include <squick/core/record_manager.h>
#include <core/data_list.h>
#include <core/i_plugin_manager.h>
#include <core/list.h>
#include <core/map.h>
#include <core/property_manager.h>
#include <core/record.h>
#include <core/record_manager.h>
#include <string>
#include <third_party/rapidxml/rapidxml.hpp>
#include <thread>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#pragma once

#include "i_common_config_module.h"
#include <squick/core/i_plugin_manager.h>
#include <squick/core/map_ex.h>
#include <squick/core/platform.h>
#include <core/i_plugin_manager.h>
#include <core/map_ex.h>
#include <core/platform.h>
class ConfigModule : public ICommonConfigModule {
public:
public:
Expand Down
File renamed without changes.
Loading

0 comments on commit d6eb338

Please sign in to comment.