Go to file
Steffen Vogel 45b4137bc4 config: add setting for database port 2022-09-19 18:15:27 +02:00
configuration config: add setting for database port 2022-09-19 18:15:27 +02:00
database config: add setting for database port 2022-09-19 18:15:27 +02:00
doc change WebRTC config format to the one of VILLASnode, add default values, update apispec #90 2022-04-20 16:45:33 +02:00
helper Updating license statement in each file and updating year and contact info in README (closes #89) 2022-04-05 16:38:25 +02:00
routes change WebRTC config format to the one of VILLASnode, add default values, update apispec #90 2022-04-20 16:45:33 +02:00
.gitignore update gitignore 2021-10-19 15:34:45 +02:00
.gitlab-ci.yml Merge branch 'fix-error-apispec' into 'master' 2022-04-14 13:29:55 +02:00
COPYING.md Initial commit 2019-03-03 15:40:38 +01:00
Dockerfile OpenAPI spec: use swag version 1.8.1 to auto-generate, fix error in result file post endpoint doc #85, update API spec 2022-04-14 11:09:04 +02:00
README.md Updating license statement in each file and updating year and contact info in README (closes #89) 2022-04-05 16:38:25 +02:00
curl_villasAPI.sh Updating license statement in each file and updating year and contact info in README (closes #89) 2022-04-05 16:38:25 +02:00
go.mod package updates 2022-04-06 11:05:38 +02:00
go.sum OpenAPI spec: use swag version 1.8.1 to auto-generate, fix error in result file post endpoint doc #85, update API spec 2022-04-14 11:09:04 +02:00
k8s_test.sh add skript to test and debug VILLASweb in our K8S cluster 2021-01-18 20:57:16 +01:00
start.go Updating license statement in each file and updating year and contact info in README (closes #89) 2022-04-05 16:38:25 +02:00

README.md

VILLASweb-backend-go

pipeline status coverage report License: GPL v3

Description

This is a rewrite of the backend for the VILLASweb website in Go. It is based upon gin-gonic and GORM frameworks.

VILLASweb API documentation (autogenerated) is available here.

Usage

Requirements

  • Go (min version 1.15), Go Modules are used for dependency management
  • PostgreSQL database (tested for version 11, instructions see below)
  • swag (https://github.com/swaggo/swag) for automated API documentation creation

Compiling

$ go mod tidy
$ go build

Testing

$ go mod tidy
$ go test $(go list ./... ) -p 1

Running

go run start.go [params]

Parameters

You can type

go run start.go --help

to get a list of available parameters and default values

Environment variables

Variable Description
DB_HOST PostgreSQL hostname
DB_NAME PostgreSQL database
DB_USER PostgreSQL username
DB_PASS PostgreSQL password
DB_SSLMODE PostgreSQL SSL enabled
AMQP_HOST AMQP hostname
AMQP_USER AMQP username
AMQP_PASS AMQP password
BASE_HOST Hostname of VILLASweb
BASE_PATH Base URL of VILLASweb
MODE Mode: debug/release/test
PORT Port on which the internal HTTP server listens
ADMIN_USER Username for initial admin user
ADMIN_PASS Password for initial admin user
ADMIN_MAIL Mail for initial admin user

PostgreSQL Database

Before running the application the user has to setup and configure PostgreSQL.

To create a new database login to user postgres and start psql

$ su - postgres
$ psql

then

CREATE DATABASE villasdb ;

Some usefull commants for psql

\c somedb -- connect to a database 
\dt       -- list all tables of the database
\l        -- list all databases

The default host for postgres is \tmp and the ssl mode is disabled in development. The user can change those setting in common/database.go.

To manage the database one can use pgAdmin4. Instructions for rpm-based distributions can be found here. The user might have to start pgAdmin as root

$ sudo pythonX /user/lib/pythonX.Y/site-packages/pgadmin4-web/pgAdmin4.py

where X.Y is the python version. The pgAdmin UI can be accessed by the browser at 127.0.0.1:5050. In case that the user is getting FATAL: Ident authentication failed for user "username" the authentication for local users has to be changed from ident to trust in pg_hba.conf file

# IPv4 local connections:
host    all             all             127.0.0.1/32            trust
# IPv6 local connections:
host    all             all             ::1/128                 trust

To do that edit the configuration file as root

$ sudo vim /var/lib/pgsql/11/data/pg_hba.conf

2022, Institute for Automation of Complex Power Systems, RWTH Aachen University

License

This project is released under the terms of the GPL version 3.

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

For other licensing options please consult Prof. Antonello Monti.

Contact

EONERC ACS Logo

Institute for Automation of Complex Power Systems (ACS)
EON Energy Research Center (EONERC)
RWTH University Aachen, Germany