Blame view

README.md 3.55 KB
a26a5bcb   hitier   Upgrade README
1
# Heliopropa Web
19268da3   Goutte   Initial commit.
2

a26a5bcb   hitier   Upgrade README
3
A web site writen in flask for the visualisation of solarwind propagation simulations.
19268da3   Goutte   Initial commit.
4

a26a5bcb   hitier   Upgrade README
5
Builds and serves heliopropa's visualizations.
19268da3   Goutte   Initial commit.
6

e5a796dc   Goutte   Update the readme...
7
It's a `flask` webserver, serving `d3.js` plots.
6b149919   Goutte   Add a Download bu...
8
It also gathers NetCDF data from AMDA, and serves it as CSV to the plotter.
19268da3   Goutte   Initial commit.
9

a26a5bcb   hitier   Upgrade README
10
## Files Overview
19268da3   Goutte   Initial commit.
11
12
13

- `config.yml` : the main configuration file.
- `web/run.py` : the front controller, holding most of the code.
6b2d7c9d   Goutte   Comment things.
14
- `web/run.log` : you'll find more information about failures in the log.
6b149919   Goutte   Add a Download bu...
15
- `web/view/home.html.jinja2` : the HTML template.
d1c44c51   Goutte   Enable Earth
16
- `web/static/js/swapp.ls` : most of the javascript client-side.
19268da3   Goutte   Initial commit.
17

265af181   hitier   Set Docker compos...
18
19
20
21
## Quick Start

    docker compose build
    docker compose up
19268da3   Goutte   Initial commit.
22

7f400160   hitier   Docker compose lo...
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
## Docker compose configuration

docker stack mainly consists in two files:

- `Dockerfile` for the container building
- `compose.yaml` for the volumes configuration and links with nginx service and gunicorn 

### Volumes configuration and `compose.override.yaml`

You may want to understand where data is stored:

The web application saves `*.csv` files in the `./cache/` directory, which happens to be a docker volume named `helio_cache`

The speasy library holds a cache dir located at `container:/root/.cache/speasy/Cache/` which is also mounted as a volume: `speasy_cache`

Two configuration files are also used:

- `./config.yml` for the web app
- `${HOME}/.config/speasy/config.ini` for the speasy library


You can use the `compose.override.yaml` file to make dynamic links between your local files and the container.
That way you can live edit the config files, and also use already loaded cache directories.

    cp compose.override.yaml-dist compose.override.yaml
    ${EDITOR} compose.override.yaml # make sure its ok, comment what you dont need
    docker compose up -d

641893b9   hitier   Add solar-orbiter...
51
52
## Develop

9ecb6089   hitier   Move config name ...
53
54
55
56
57
58
59
### Configuration

``` bash
cp config.yml-dist config.yml
$(EDITOR) config.yml # but defaults should be ok
```

29551a9f   hitier   Update prerequisites
60
61
### Python venv

19268da3   Goutte   Initial commit.
62
``` bash
1db3095f   hitier   Update dependencies
63
python3 -m venv venv
19268da3   Goutte   Initial commit.
64
source venv/bin/activate
19268da3   Goutte   Initial commit.
65
66
67
pip install -r requirements.txt
```

641893b9   hitier   Add solar-orbiter...
68
### Run locally
19268da3   Goutte   Initial commit.
69
70
``` bash
source venv/bin/activate
206d8d14   Goutte   Clean up.
71
DEBUG=true python web/run.py
19268da3   Goutte   Initial commit.
72
73
74
```

Then, browse [localhost:5000](http://localhost:5000).
5ef50583   Goutte   Clean up.
75

a26a5bcb   hitier   Upgrade README
76
## Gunicorn and Nginx deployment on OVH for development
8cfeb607   hitier   More install and ...
77
78
79
80

see [ Digital Ocean documentation ] (https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-ubuntu-20-04-fr)


a26a5bcb   hitier   Upgrade README
81
### wep app service and Gunicorn
8cfeb607   hitier   More install and ...
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100

see ./resources/heliopropa.service

/etc/systemd/system/heliopropa.service

    [Unit]
    Description=Gunicorn instance to serve Heliopropa
    After=network.target

    [Service]
    User=debian
    Group=www-data
    WorkingDirectory= /home/debian/heliopropa/
    Environment="PATH=/home/debian/heliopropa/venv/bin/"
    ExecStart=/home/debian/heliopropa/venv/bin/gunicorn --workers 3 --bind unix:heliopropa.sock -m 007 web.run:app

    [Install]
    WantedBy=multi-user.target

a26a5bcb   hitier   Upgrade README
101
### Nginx
8cfeb607   hitier   More install and ...
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117

see ./resources/heliopropa.nginx

/etc/nginx/sites-available/heliopropa

	server {
		listen 80;
		server_name heliopropa heliopropa.co-libri.org;

		location / {
			include proxy_params;
			proxy_pass http://unix:/home/debian/heliopropa/heliopropa.sock;
		}
	}


a26a5bcb   hitier   Upgrade README
118
### Start and Allow at system reboot
8cfeb607   hitier   More install and ...
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142

	sudo systemctl start nginx
	sudo systemctl start heliopropa 
	sudo systemctl enable heliopropa 


## Git hook auto deploy

see ./resources/post-receive.git-hook

Set bare repo with hook  on vps

    ssh user@vps
    git clone --bare path-to-heliopropa-repo heliopropa.git
    cd heliopropa.git/hooks
    vim post-receive
    chmod +x post-receive



Push from dev computer

    git remote add helio-dev user@vps:heliopropa.git
    git push heliopropa HEAD:DEV