Skip to content

open-v2x/dandelion

Repository files navigation

OpenV2X Device Management - APIServer

pep8 ci issue star license

English | 简体中文

Table of contents

Configuration

  • Sample File: dandelion.conf.sample
  • First of all, you need to copy the configuration file from sample.

    cp etc/dandelion/dandelion.conf.sample etc/dandelion/dandelion.conf
  • Generally, you should change the following values:

    [DEFAULT]
    debug: true
    log_file: dandelion.log
    log_dir: /var/log/dandelion
    
    [cors]
    origins: *
    
    [database]
    connection: mysql+pymysql://dandelion:dandelion@127.0.0.1:3306/dandelion
    
    [mqtt]
    host: 127.0.0.1
    port: 1883
    username: root
    password: 123456
    
    [redis]
    connection: redis://root:123456@127.0.0.1:6379?db=0&socket_timeout=60&retry_on_timeout=yes
    
    [token]
    expire_seconds: 604800
  • At last, you can link the etc/dandelion/dandelion.conf to the /etc/dandelion/dandelion.conf file.

    mkdir -p /etc/dandelion
    DANDELION_PATH=`pwd`
    cd /etc/dandelion
    ln -s ${DANDELION_PATH}/etc/dandelion/dandelion.conf dandelion.conf

Build && Run (Linux)

  • Build docker image.

    RELEASE_VERSION=`git rev-parse --short HEAD`_`date -u +%Y-%m-%dT%H:%M:%S%z`
    GIT_BRANCH=`git rev-parse --abbrev-ref HEAD`
    GIT_COMMIT=`git rev-parse --verify HEAD`
    docker build --no-cache --pull --force-rm --build-arg RELEASE_VERSION=${RELEASE_VERSION} --build-arg GIT_BRANCH=${GIT_BRANCH} --build-arg GIT_COMMIT=${GIT_COMMIT} -f Dockerfile -t dandelion:latest .
  • Run dandelion service as container.

    mkdir -p /var/log/dandelion
    docker run -d --name dandelion_bootstrap -e KOLLA_BOOTSTRAP="" -v /etc/dandelion/dandelion.conf:/etc/dandelion/dandelion.conf --net=host dandelion:latest
    docker rm dandelion_bootstrap
    docker run -d --name dandelion --restart=always -v /etc/dandelion/dandelion.conf:/etc/dandelion/dandelion.conf -v /var/log/dandelion:/var/log/dandelion --net=host dandelion:latest

Local Development (Linux)

Run server

  • Before you run the dandelion server, you need to follow the Configuration section.

    tox -e venv
    source .tox/venv/bin/activate
    uvicorn --reload --reload-dir dandelion --port 28300 --log-level debug dandelion.main:app --host 0.0.0.0
  • You can visit the OpenAPI swagger document at http://127.0.0.1:28300/docs

Alembic (Database Migration)

  • Generate the migration script.

    tox -e venv
    source .tox/venv/bin/activate
    alembic revision --autogenerate -m "xxxx"
  • Run the migration script and update the database.

    tox -e venv
    source .tox/venv/bin/activate
    alembic upgrade head

Tox Tools

  • Generate the latest swagger file.

    tox -e genswagger
  • Generate the latest sample config file.

    tox -e genconfig
  • Code format and style check.

    tox -e pep8-format
    tox -e pep8

Apitest

  • install requirement

    pip3 install gabbi
  • execute test

    ls apitest/*.yaml | xargs gabbi-run 139.196.13.9:28300 --
    ls apitest/*.yaml | xargs gabbi-run localhost:28300 --
    
    # show verbose
    gabbi-run -v all 139.196.13.9:28300 -- apitest/*.yaml
    gabbi-run -v all localhost:28300 -- apitest/*.yaml

Notice

  • Please run dprint fmt to format markdown files before creating PR.

About

OpenV2X Device Management - APIServer (Manage wherever the wind goes)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages