Git Product home page Git Product logo

vinbero_mt_epoll_http's Introduction

Vinbero Tweet

GitHub release Build Status license Docker Stars Docker Pulls codecov

VinberoVinbero

Intoduction

Vinbero is a modular server written in C, and its main goal is flexibility. Its core is very small; It just loads children modules, initializes them, calls callbacks on them and destroys them. Currently multithreading, tcp, epoll, tls, http, lua modules exist. So you can try it as a simple web application server with lua scripting. But if you add your own module it could be even used as a mailserver, chatserver or gameserver.

Installation

Core only

docker pull vinbero/vinbero

Core and official modules

docker pull vinbero/vinbero_mt_http_lua

Example

docker run -it -d --name vinbero -p 8080:80 vinbero/vinbero_mt_http_lua
curl localhost:8080

docker run -it -d --name vinbero -p 8080:80 -e PASSWORD=<YOUR PASSWORD> vinbero/vinbero-blog
#default id: 'admin', default password: 'password'
ngrok http 8080

Youtube link

Warning

Currently this software is under heavy development, so there will be bugs or the architecture can change. Writing new modules is not encouraged yet.

Usage

Usage: vinbero [OPTION]...
A Modular Server.
Options:
  -i --inline-config       Inline JSON-based config.
  -c --config-file         JSON-based config file.
  -f --logging-flag        Set logging level flag.
  -o --logging-option      Set logging option.
  -v --version             Print version info.
  -h --help                Print this help message.

Config file example

{
    "core": {
        "config": {"vinbero.setUid": 1001},
        "next": ["vinbero_tcp"]
    },
    "vinbero_tcp": {
        "paths": ["/usr/local/lib/vinbero/vinbero_tcp.so", "/usr/lib/vinbero/vinbero_tcp.so"],
        "config": {"vinbero_tcp.port": 80, "vinbero_tcp.reuseAddress": true},
        "next": ["vinbero_mt"]
    }, 
    "vinbero_mt": {
        "paths": ["/usr/local/lib/vinbero/vinbero_mt.so", "/usr/lib/vinbero/vinbero_mt.so"],
        "config": {"vinbero_mt.workerCount": 4},
        "next": ["vinbero_strm_mt_epoll"]
    },
    "vinbero_strm_mt_epoll": {
        "paths": ["/usr/local/lib/vinbero/vinbero_strm_mt_epoll.so", "/usr/lib/vinbero/vinbero_strm_mt_epoll.so"],
        "config": {"vinbero_strm_mt_epoll.clientTimeoutSeconds": 3},
        "next": ["vinbero_mt_epoll_http"]
    },
    "vinbero_mt_epoll_http": {
        "paths": ["/usr/local/lib/vinbero/vinbero_mt_epoll_http.so", "/usr/lib/vinbero/vinbero_mt_epoll_http.so"],
        "config": {},
        "next": ["vinbero_mt_http_lua"]
    },
    "vinbero_mt_http_lua": {
        "paths": ["/usr/local/lib/vinbero/vinbero_mt_http_lua.so", "/usr/lib/vinbero/vinbero_mt_http_lua.so"],
        "config": {
            "vinbero_mt_http_lua.scriptFile": "/srv/app.lua",
            "vinbero_mt_http_lua.scriptArg": {}
        },
        "next": []
    }
}

Logging flags and Logging options

Logging flags and logging options are integer bitmasks:

  • FLAG_TRACE: 1
  • FLAG_DEBUG: 2
  • FLAG_INFO: 4
  • FLAG_WARN: 8
  • FLAG_ERROR: 16
  • FLAG_FATAL: 32
  • default logging flag is 62
  • OPTION_COLOR: 1
  • OPTION_SOURCE: 2
  • defualt logging option is 1

Core module config options

  • vinbero.setUid (int) : Change uid after module initialization.
  • vinbero.setGid (int) : Change gid after module initialization.

History

It is initially started as a hobby project by Byeonggon Lee at Jul, 2016. There have been many architectural changes.

License

MPL-2.0

Contribution guide

Any type of contribution is welcome! Radical changes like function renaming or small changes like removing extra spacing is allowed too. Please don't hesitate to fork and contribute, this project needs a lot of work to do.

Language

Use English on your commit message so everyone can understand

Naming convention

Modules

Module names are snake case, and should be start with vinbero_

Example
vinbero_mt_epoll_http
vinbero_mt

Interfaces

Interface names are snake case and should start with vinbero_iface and interface part must be uppercase with underscore.

Example
vinbero_iface_HTTP

Structs

Struct names are pascal case and start with module names or interface names.

Example
struct vinbero_mt_epoll_http_Module;
struct vinbero_mt_epoll_http_ParserData;

Functions

Function names are camel case and start with struct names if it act like methods, or start with module names or interface names.

Example
int vinbero_strm_mt_epoll_loadChildClModules(struct vinbero_com_ClModule* clModule);
int vinbero_iface_HTTP_onRequestStart(struct vinbero_com_ClModule* clModule);

Macros

Macro naming is same as C macros (uppercase with underscore). But it also starts with module names or interfaces names.

Example

#define VINBERO_INTERFACE_HTTP_DLSYM(interface, dlHandle, ret)

Variables

Struct variable names are same as function names. but local variables don't start with module names

Reserved namespaces

  • vinbero_core
  • vinbero_com
  • vinbero_iface
  • vinbero_global
  • vinbero_static
  • vinbero_local

Versioning

This project follows semantic versioning

Branching

This project and all sub-projects are going to follow this branching model after vinbero v0.1.0 release.

  • master: Should always be executed without a bug.
  • dev: Development branch, can contain a bug
  • feature: When creating a new feature. this branch will be merged into dev branch
  • release: When creating a new release. this branch will be merged into master branch
  • hotfix: When a bug is found on master branch and you need to fix it fast, create this branch and merge it into master branch
  • bugfix: When a bug is found on dev branch, create this branch and merge it into dev branch

Example

  1. To start developing from the environment where all official modules are installed, run a docker container like this:
docker run --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -it -d --name vinbero vinbero/vinbero_mt_http_lua:dev
docker exec -it vinbero /bin/zsh
  1. Inside the container clone a forked repository, start from a branch you want to improve e.g., dev, feature, release, hotfix, bugfix
cd /
rm -rf vinbero
git clone -b dev https://github.com/YOU/vinbero
  1. Checkout to a new branch
git checkout -b feature-something or git checkout
  1. Edit sources, run cmake, commit and push
  2. Make a pull request

vinbero_mt_epoll_http's People

Contributors

binkoni avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.