一、编译Skynet:
1、用ubuntu15.10直接
make linux编译Skynet会有报错。安装autoconf、libreadline6、libreadline6-dev后就能编译成功了。
sudo apt-get install autoconf
sudo apt-get install libreadline6 libreadline6-dev
二、关于examples相关的代码分析:
1、关于examples/config里面有一行:
start = "main" -- main script意思是通过start="main"开启第一个Skynet的服务main.lua。这个文件main.lua也在examples文件夹中:
local skynet = require "skynet"
local sprotoloader = require "sprotoloader"
local max_client = 64
skynet.start(function()
skynet.error("Server start")
skynet.uniqueservice("protoloader")
if not skynet.getenv "daemon" then
local console = skynet.newservice("console")
end
skynet.newservice("debug_console",8000)
skynet.newservice("simpledb")
local watchdog = skynet.newservice("watchdog")
skynet.call(watchdog, "lua", "start", {
port = 8888,
maxclient = max_client,
nodelay = true,
})
skynet.error("Watchdog listen on", 8888)
skynet.exit()
end)

本文从零开始介绍如何编译Skynet,并深入解析examples/config中的主要服务,包括skynet.start()、skynet.newservice()、skynet.call()、skynet.exit()和skynet.monitor()的使用。通过main.lua启动的服务如service_mgr、console、simpledb和watchdog,展示了Skynet框架的基本操作。watchdog服务监听8888端口,agent服务处理数据并传递给simpledb进行Key-Value处理。这是一个初步了解Skynet lua接口的起点。
最低0.47元/天 解锁文章
2874

被折叠的 条评论
为什么被折叠?



