Die Migration der Bereiche "Docker Registry" und "Artifiacts" ist fast abgeschlossen. Die letzten Daten werden im Laufe des heutigen Abend (05.08.2021) noch vollständig hochgeladen. Das Anlegen neuer Images und Artifacts funktioniert bereits wieder.

README.md 4.87 KB
Newer Older
Sonja Happ's avatar
Sonja Happ committed
1
# <img src="doc/pictures/villas_web.png" width=40 /> VILLASweb-backend-go
Stefanos Mavros's avatar
Stefanos Mavros committed
2

Steffen Vogel's avatar
Steffen Vogel committed
3
4
[![pipeline status](https://git.rwth-aachen.de/acs/public/villas/web-backend-go/badges/master/pipeline.svg)](https://git.rwth-aachen.de/acs/public/villas/web-backend-go/commits/master)
[![coverage report](https://git.rwth-aachen.de/acs/public/villas/web-backend-go/badges/master/coverage.svg)](https://git.rwth-aachen.de/acs/public/villas/web-backend-go/commits/master)
Sonja Happ's avatar
Sonja Happ committed
5
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
6

Stefanos Mavros's avatar
Stefanos Mavros committed
7
## Description
Sonja Happ's avatar
Sonja Happ committed
8
9
This is a rewrite of the backend for the VILLASweb website in Go.
It is based  upon [gin-gonic](https://github.com/gin-gonic/gin) and [GORM](http://gorm.io) frameworks.
Stefanos Mavros's avatar
Stefanos Mavros committed
10

Sonja Happ's avatar
Sonja Happ committed
11
12
VILLASweb API documentation (autogenerated) is available [here](doc/api/swagger.yaml).

Sonja Happ's avatar
Sonja Happ committed
13
## Usage
Stefanos Mavros's avatar
Stefanos Mavros committed
14

Sonja Happ's avatar
Sonja Happ committed
15
### Requirements
16
- Go (min version 1.15), Go Modules are used for dependency management
Sonja Happ's avatar
Sonja Happ committed
17
18
- PostgreSQL database (tested for version 11, instructions see below)
- swag (https://github.com/swaggo/swag) for automated API documentation creation 
Stefanos Mavros's avatar
Stefanos Mavros committed
19

20
21
22
23
24
25
26
27
28
29
### Compiling

```bash 
$ go mod tidy
$ go build
```

### Testing
```bash 
$ go mod tidy
Sonja Happ's avatar
Sonja Happ committed
30
$ go test $(go list ./... ) -p 1
31
32
```

Sonja Happ's avatar
Sonja Happ committed
33
34
35
36
### Running
```bash
go run start.go [params]
```
37

Sonja Happ's avatar
Sonja Happ committed
38
39
40
41
42
43
### Parameters
You can type
 ```bash
go run start.go --help
```
to get a list of available parameters and default values
44

45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
## 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						|
64

Sonja Happ's avatar
Sonja Happ committed
65
## PostgreSQL Database
66
Before running the application the user has to setup and configure
Sonja Happ's avatar
Sonja Happ committed
67
[PostgreSQL](https://www.postgresql.org/). 
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89

To create a new database login to user `postgres` and start `psql`
```bash
$ su - postgres
$ psql
```
then
```sql
CREATE DATABASE villasdb ;
```

Some usefull commants for `psql`
```sql
\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`.

90
91
92
93
94
95
96
97
To manage the database one can use [pgAdmin4](https://www.pgadmin.org/).
Instructions for rpm-based distributions can be found
[here](https://computingforgeeks.com/how-to-install-pgadmin-4-on-centos-7-fedora-29-fedora-28/).
The user might have to start pgAdmin as root
```bash
$ 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
Sonja Happ's avatar
Sonja Happ committed
98
browser at `127.0.0.1:5050`. In case that the user is getting `FATAL:
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
Ident authentication failed for user "username"` the authentication for
local users has to be changed from `ident` to `trust` in `pg_hba.conf`
file
```text
# 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
```bash
$ sudo vim /var/lib/pgsql/11/data/pg_hba.conf
```

Stefanos Mavros's avatar
Stefanos Mavros committed
114
115
## Copyright

Sonja Happ's avatar
Sonja Happ committed
116
2020, Institute for Automation of Complex Power Systems, EONERC  
Stefanos Mavros's avatar
Stefanos Mavros committed
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142

## License

This project is released under the terms of the [GPL version 3](COPYING.md).

```
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](mailto:amonti@eonerc.rwth-aachen.de).

## Contact

[![EONERC ACS Logo](doc/pictures/eonerc_logo.png)](http://www.acs.eonerc.rwth-aachen.de)

Sonja Happ's avatar
Sonja Happ committed
143
 - Sonja Happ: <sonja.happ@eonerc.rwth-aachen.de>
Stefanos Mavros's avatar
Stefanos Mavros committed
144
145
146
147

[Institute for Automation of Complex Power Systems (ACS)](http://www.acs.eonerc.rwth-aachen.de)  
[EON Energy Research Center (EONERC)](http://www.eonerc.rwth-aachen.de)  
[RWTH University Aachen, Germany](http://www.rwth-aachen.de)