GDK 商用异端框架 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
MiguelValentine
V2EX    Node.js

GDK 商用异端框架

  •  2
     
  •   MiguelValentine 2015 年 12 月 14 日 4320 次点击
    这是一个创建于 3717 天前的主题,其中的信息可能已经有所发展或是发生改变。

    https://github.com/MiguelValentine/GDK
    欢迎 issues

    GDK

    GDK is a global based framework for node.

    Installation

    $ npm install gdk 

    Features

    • No export And require.
    • NO third-module.
    • Micro enough.
    • Flat.
    • Support command.
    • Support Cluster Mode.
    • Locked global error,never shut down.

    Docs & Community [还在筹备]

    Quick Start

    No.GDK dose not support quick start.And I will not provide a generator.

    I don't think less is best.I can guide you to make your our service different with anyone.

    At First make sure that your env is in your project and you npm installed gdk.

    You can download Learning Project.

    1.Create bin File to guide - bin/start.js

    require('gdk') var baseDir = __dirname; gdk.load(gdk.c.path.join(baseDir,'../config')); gdk.boot(); gdk.load(gdk.c.path.join(baseDir,'../http')); gdk.cluster(function(){ gdk.http.boot(); }); 

    2.Create config File - config/index.js

    var baseFile = __filename; gdk.updatePath.cOnfig= baseFile; gdk.config.Mcores = true; gdk.config.errLog = gdk.c.path.join(__dirname,'../err.log'); gdk.config.port = 3000; 

    3.Create http base - http/index.js

    gdk.updatePath.http = __filename; gdk.http = {}; gdk.load(gdk.c.path.join(__dirname,'./router')); gdk.load(gdk.c.path.join(__dirname,'./flow')); gdk.load(gdk.c.path.join(__dirname,'./instance')); 

    4.Create flow file - http/flow/index.js

    gdk.http.flow = function(req,res){ if(gdk.http.router[gdk.c.url.parse(req.url).path]){ gdk.http.router[gdk.c.url.parse(req.url).path](req,res); }else{ res.end(); } } 

    5.Create router file - http/router/index.js

    gdk.http.router = {}; gdk.http.router['/'] = function(req,res){ res.end('Hello World!'); } 

    6.Create instance file - http/instance/index.js

    gdk.http.server = function(req,res){ gdk.http.flow(req,res); }; gdk.http.boot = function(){ var server = gdk.c.http.createServer(gdk.http.server); server.on('error',function(err){ gdk.errCatch('server err',err); }); server.listen(gdk.config.port); }; 

    7.Run

    node bin/start.js 

    Command

    1.bash command

    Example:
    bash
    bash---console.log(gdk.config)

    2.Hot-update command

    Example:
    bash
    update---config

    Example2:
    bash
    upfile---/node/http/index.js

    3.Your command

    Example:

    gdk.runTime.print = function(info){
    console.log(info)
    }

    print---here is a test 

    Cluster message I/O

    In gdk Cluster mode.gdk.cluster(cb).cb will always run on workers.

    Workers can use process.send to call a runtime function in all workers or master.

    Example:
    ```
    gdk.runTime.print = function(a,b){
    console.log(a+b)
    }

    process.send({bash:'print',arg:{'hello',' world'}});
    ```

    Example:
    ```
    gdk.runTime.MainCore = function(a,b){
    console.log(a+b)
    }

    process.send({bash:'MainCore',arg:{'hello',' world'},Master:true});
    ```

    geminiyellow
        1
    geminiyellow  
       2015 年 12 月 14 日   1
    good job !不顶不是中国人。
    zenwong
        2
    zenwong  
       2015 年 12 月 14 日
    不好意思,我们又一次没捆严实他,让他从 cnodejs 跑到这里来了,这是我们深圳 node.js 大本营群( 364189010 )的失误。抱歉抱歉。( A :这次广告是不是又有点硬了? B :别哔哔,快走,不然一会还要被打。)
    zenwong
        3
    zenwong  
       2015 年 12 月 14 日   1
    GuaPiJS 你值得信赖,作者比代码更帅。
    denghongcai
        4
    denghongcai  
       2015 年 12 月 14 日   1
    GDK ,走向成功的最好垫脚石
    mcfog
        5
    mcfog  
       2015 年 12 月 14 日
    扫了一眼,没看明白干啥用的,只看到

    > Locked global error,never shut down.

    死刑。

    回头一想不能冤枉人啊,点进去搜了一把

    https://github.com/MiguelValentine/GDK/blob/5502399d0489a2d64cd7e03741df5922f80b1ef5/err/index.js#L16

    核准判决有效,立即执行

    不解释
    MiguelValentine
        6
    MiguelValentine  
    OP
       2015 年 12 月 14 日
    @mcfog 所以你家项目怎么 7x24 ? pm2?
    MiguelValentine
        7
    MiguelValentine  
    OP
       2015 年 12 月 14 日
    @mcfog 你要是有本质上能解决错误的方法你可以发 pr 。我这种方法中断单 req 比 refork 强的的多。
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     1937 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 31ms UTC 03:05 PVG 11:05 LAX 19:05 JFK 22:05
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86