Code Monkey home page Code Monkey logo

pengge / adminservice Goto Github PK

View Code? Open in Web Editor NEW

This project forked from li9chuan/adminservice

0.0 0.0 0.0 19.48 MB

C++服务管理工具&cmd。管理C++服务,远程命令执行。包含AdminModule(lib,用于目标进程),AdminService(web交互),web(前端)三个工程。

Home Page: http://admin.mulanshanzhuang.com

License: GNU General Public License v3.0

CMake 6.09% C++ 90.97% C 0.77% Batchfile 0.07% Shell 0.23% HTML 0.40% TSQL 0.04% JavaScript 0.44% Vue 0.94% CSS 0.05%

adminservice's Introduction

C++服务管理工具&cmd远程执行

管理C++进程或服务,以及远程命令执行。包含AdminModule(lib,用于目标进程),AdminService(web交互),web(前端)三个工程。 DEMO: http://admin.mulanshanzhuang.com

在原有进程中包含AdminModule库,初始化后即可连接AdminService,windows可以启动以下批处理测试服务:

AdminModule\code\test\app\start_connect_test_svr.bat

img

一、定义命令&连接管理器

1. 项目需要包含AdminModule生成的静态库(nelmisc nelnet),增加.h包含目录 AdminModule\code\nel\include\*
2. #include "nel/net/admin_module.h"
3. 初始化服务管理模块
AdminModule.initAdmin( AdminService host:port, 片区, 进程类型, SvrID );
4. 主循环中调用update
AdminModule.updateAdmin();
5. 结束前调用release
AdminModule.releaseAdmin();
6. 定义Command
// I want to create a function that computes the square of the parameter and display the result
NLMISC_COMMAND(square,"display the square of the parameter","<value>")
{
	// check args, if there s not the right number of parameter, return bad
	if(args.size() != 1) return false;
	// get the value
	uint32 val;
	fromString(args[0], val);
	// display the result on the displayer
	log.displayNL("The square of %d is %d", val, val*val);
	return true;
}
7. 进程连接AdminService后,通过web端调用Command

img


二、AdminService编译

1.AdminService linux编译,依赖protobuf3,libevent,openssl,mysql,zlib

pwd
/xxxx/xxxx/AdminService/code
cd ..
mkdir build
cd build
cmake ../code
make

img

make install

img

2.AdminService win编译

创建build目录,解压 external.7z,external中是vs2012依赖库,目录结构如下:

AdminService\build
AdminService\code
AdminService\external

使用CMake构建vs2012工程 img

工程生成在build目录,Open Project: img

三、web端

使用vue.js ,依赖工具

nodejs                  // https://nodejs.org/en/
yarn                    // npm install -g yarn
                        // yarn config set registry https://registry.npm.taobao.org
@vue-cli                // yarn global add @vue/cli

安装后,进入目录 ./AdminService/AdminWeb/ 输入yarn install 更新项目的依赖库。 开始运行中输入 vue ui 启动控制台,加载项目AdminWeb。

修改连接到的AdminService:

Vue.use(VueNativeSock, 'ws://admin.mulanshanzhuang.com:10390',

四、代码索引

AdminModuel

void sendMsg ( const CMessage& );   // 发消息到AdminService
void addCallbackArray (const TCallbackItem *callbackarray, sint arraysize); // 回调

AdminService

AdminService\tools\protobuf             // 与前端通信的proto目录
AdminService\code\EVA\server\msg.xml    // web消息过滤&proto反射
m_CallbackAdminModule.addCallbackArray  // AdminModule回调注册
m_CallbackWebSocket.addCallback         // web回调注册

web

switch(json['msgtype'])                                // 收消息处理
this.$socket.send( JSON.stringify(MsgExecCommand) );   // .vue 发送消息到AdminService

adminservice's People

Contributors

li9chuan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.