local skynet = require "skynet"
local gLog = gLog
-----------------------------------------------------------------------------

local M = {}

-----------------------------------------------------------------------------
-- 启动master
--  listen_addr: 管理工具监听端口 例:"0.0.0.0:8000"
function M.start_master(listen_addr)
    local master = skynet.uniqueservice("swt/master")
    gLog.info("[swt:start_master] listen_addr", listen_addr, " addr ", master)
    skynet.send(master, "lua", "start", listen_addr)
end

-----------------------------------------------------------------------------
-- 启动agent
--  node_type: 节点类型名
--  node_name: 节点名
--  listen_addr: 监听地址 例:"127.0.0.1:8001"
function M.start_agent(node_type, node_name, listen_addr)
    -- 启动 prometheus
    local prometheus_addr = skynet.uniqueservice("swt/prometheus")

    -- 启动 profiler
    local agent_addr = skynet.uniqueservice("swt/agent")
    gLog.info("[swt:start_agent] node_type node_name listen_addr addr", node_type, node_name, listen_addr, agent_addr,
        prometheus_addr)
    skynet.send(agent_addr, "lua", "start", node_type, node_name, listen_addr, prometheus_addr)
end

return M
