314bc5df
zhengshouren
提交服务器初始代码
|
1
2
|
local skynet = require "skynet"
|
8518549a
zhouhaihai
类型错误
|
3
|
local max_client = tonumber(skynet.getenv("max_client"))
|
5e6af9d6
zhouhaihai
排队功能
|
4
|
local max_queue = tonumber(skynet.getenv("max_queue"))
|
3f604f2e
zhouhaihai
扩容 redis 和 log服务
|
5
6
|
local work_count = tonumber(skynet.getenv("thread"))
local use_logd = tonumber(skynet.getenv("logd"))
|
314bc5df
zhengshouren
提交服务器初始代码
|
7
8
9
|
skynet.start(function()
print("Server start")
|
8518549a
zhouhaihai
类型错误
|
10
|
skynet.newservice("debug_console", tonumber(skynet.getenv("debug_port")))
|
314bc5df
zhengshouren
提交服务器初始代码
|
11
|
|
3f604f2e
zhouhaihai
扩容 redis 和 log服务
|
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
-- 启动redis
for i = 1, work_count do
local redisd = skynet.newservice("services/redisd", i)
skynet.call(redisd, "lua", "open", {
redishost = skynet.getenv("redis_host"),
redisport = tonumber(skynet.getenv("redis_port")),
redisdb = tonumber(skynet.getenv("redis_db")),
auth = skynet.getenv("redis_auth")
})
end
--启动log
if use_logd == 1 then
|
c06bf6ed
zhouhaihai
增加log 服务数量
|
26
|
for i = 1, work_count * 2 do
|
3f604f2e
zhouhaihai
扩容 redis 和 log服务
|
27
28
29
30
31
|
local logd = skynet.newservice("services/logd", i)
skynet.call(logd, "lua", "open")
end
end
|
8518549a
zhouhaihai
类型错误
|
32
|
local httpd = skynet.newservice("services/httpweb", tonumber(skynet.getenv("httpweb_port")))
|
314bc5df
zhengshouren
提交服务器初始代码
|
33
|
local watchdog = skynet.newservice("services/watchdog", max_client)
|
3fe4471e
zhouhaihai
热更新 demo
|
34
|
|
3f604f2e
zhouhaihai
扩容 redis 和 log服务
|
35
|
|
314bc5df
zhengshouren
提交服务器初始代码
|
36
|
skynet.call(watchdog, "lua", "start", {
|
8518549a
zhouhaihai
类型错误
|
37
|
port = tonumber(skynet.getenv("server_port")),
|
5e6af9d6
zhouhaihai
排队功能
|
38
|
maxclient = max_client + max_queue + 10,
|
3fe4471e
zhouhaihai
热更新 demo
|
39
|
httpd = httpd,
|
314bc5df
zhengshouren
提交服务器初始代码
|
40
41
42
43
|
})
skynet.exit()
end)
|