VSCode的SSH Remote插件使用

Blues

一个基于Openresty的WEB演示框架? 最开始是想用OpenRest+Lua实现一个Web框架? 后期发现Lua不太适合做Web开发, 即使像MoonScript这样的语言实现起一些Web的功能,相对也比较麻烦,而且,其他语言在Web开发方面可能更合适?

一个基于Openresty、Lua的WEB演示框架,提供了简单的路由服务,并且可以用创建一个基于OpenResty的Web网站站点,提供Markdown文件的变更监控,Markdown文件到HTML文件的静态站翻译过程。

Lua语言,更适合控制OpenResty,开发其扩展功能。为了能让这个项目后续,把这个软件的定位,从一个基于OpenResty的Lua框架? 变成一个静态网站的生成工具?

像优秀的Ruby静态网站工具Jekyll一样,首先我们要致敬Jekyll,同时我们要开发出一种个性化的Markdown组织体系,依托于OpenResty本身的高性能?

原有的框架是没有Build命令的,我们加入Build功能,用于进行Markdown文件的翻译工作。也启动、关闭、构建,文件变化实时监控、日志、模板等功能?

#命令

可以通简单的命令快速的生成Openresty的配置文件和目录结构?

1.安装

git clone https://github.com/shengnoah/blues.git
cd blues
sudo sh install.sh

2.创建项目

hi new blues

3.创建应用

local bjson = require "utils.bjson"
local app = require "blues"

app:get("/blues", function(self)
    return "blues"
end)

app:get("/json", function(self)
    local t = bjson.decode(self.req.body)
    return t   
end)

return app 

4.启动服务

hi start 
hi stop 
hi restart 

5.测试服务

测试接口?

curl -X GET  http://0.0.0.0:8888/json -d  '{"key":"value"}'

返回结果?

{"key":"value"}

#generated by `web framework`

# user www www;
pid tmp/dev-nginx.pid;

# This number should be at maxium the number of CPU on the server
worker_processes 4;

events {
    # Number of connections per worker
    worker_connections 4096;
}

http {
    # use sendfile
    sendfile on;
    # include #NGX_PATH/conf/mime.types;

    # framework initialization
    lua_package_path "./?.lua;./app/?.lua;/usr/local/hi/fw/?.lua;/usr/local/hi/libs/moon/?.lua;./?.lua;/usr/local/hi/?.lua;/usr/local/hi/?/init.lua;;";
    lua_package_cpath "./app/library/?.so;/usr/local/hi/fw/?.so;/usr/local/hi/libs/moon/?.so;/usr/local/hi/?.so;;";
    lua_code_cache off;
    #LUA_SHARED_DICT


    server {
        # List port
        listen 8888;
        set $template_root '';

        location /static {
            alias ./app/static; #app/static;
        }

        # Access log with buffer, or disable it completetely if unneeded
        access_log logs/dev-access.log combined buffer=16k;
        # access_log off;

        # Error log
        error_log logs/dev-error.log;

        # framework runtime
        location / {
            #content_by_lua_file ./app/app.lua;
            content_by_lua '
                app = require("app")
                app.run()
            ';

        }
    }
}

6.操作命

6.1 new: 新成生一个基于OpenResty有的HTTP项目。

6.2 start:启动这个Web服务。

6.3 stop:关闭Web服务。

6.4 build:将Markdown文件生成静态HTML。

6.5 watch:监控Markdown文件的变化。

7.排错

7.1 环境变量

如果提示系统找不到Nginx, 添加下面的PATH配置语句。

PATH=$PATH:/usr/local/openresty/nginx/sbin
export PATH
Edit me