美文网首页
skynet教程(0)--skynet的获取和编译

skynet教程(0)--skynet的获取和编译

作者: 天一阁图书管理员 | 来源:发表于2017-08-31 11:00 被阅读288次

    作者:shihuaping0918@163.com,转载请注明作者

    本篇作为skynet的开篇,主要是介绍skynet基本环境的搭建以及知识储备。怎么获取skynet的源码,怎么编译。目前的skynet版本是1.1,是云风最近一次发布的。本篇只涉及linux下的环境搭建,不介绍windows下的相关内容,windows下要搭建请自行google。

    机器环境准备:linux/mac一台。git客户端安装好。gcc编译工具安装好。

    项目源码:
    https://github.com/cloudwu/skynet

    源码下载
    git clone https://github.com/cloudwu/skynet.git

    源码编译

    make linux
    如果是mac
    make macosx
    

    编译不需要太久,如果网速比较快的话。编译完成后,在skynet目录下会生成一个skynet可执行文件。

    验证编译是否成功

    [:01000001] LAUNCH logger 
    [:01000002] LAUNCH snlua bootstrap
    [:01000003] LAUNCH snlua launcher
    [:01000004] LAUNCH snlua cmaster
    [:01000004] master listen socket 0.0.0.0:2013
    [:01000005] LAUNCH snlua cslave
    [:01000005] slave connect to master 127.0.0.1:2013
    [:01000006] LAUNCH harbor 1 16777221
    [:01000004] connect from 127.0.0.1:50171 4
    [:01000004] Harbor 1 (fd=4) report 127.0.0.1:2526
    [:01000005] Waiting for 0 harbors
    [:01000005] Shakehand ready
    [:01000007] LAUNCH snlua datacenterd
    [:01000008] LAUNCH snlua service_mgr
    [:01000009] LAUNCH snlua main
    [:01000009] Server start
    [:0100000a] LAUNCH snlua protoloader
    [:0100000b] LAUNCH snlua console
    [:0100000c] LAUNCH snlua debug_console 8000
    [:0100000c] Start debug console at 127.0.0.1:8000
    [:0100000d] LAUNCH snlua simpledb
    [:0100000e] LAUNCH snlua watchdog
    [:0100000f] LAUNCH snlua gate
    [:0100000f] Listen on 0.0.0.0:8888
    [:01000009] Watchdog listen on 8888
    [:01000009] KILL self
    [:01000002] KILL self
    

    另开一个窗口,cd到skynet目录

    ./3rd/lua/lua ./examples/client.lua 
    Request:    1
    Request:    2
    RESPONSE    1
    msg Welcome to skynet, I will send heartbeat every 5 sec.
    RESPONSE    2
    REQUEST heartbeat
    REQUEST heartbeat
    REQUEST heartbeat
    REQUEST heartbeat
    REQUEST heartbeat
    REQUEST heartbeat
    REQUEST heartbeat
    REQUEST heartbeat
    REQUEST heartbeat
    REQUEST heartbeat
    REQUEST heartbeat
    REQUEST heartbeat
    

    退出都按ctrl+c。

    相关文章

      网友评论

          本文标题:skynet教程(0)--skynet的获取和编译

          本文链接:https://www.haomeiwen.com/subject/oymidxtx.html