Blame view

README.md 4.01 KB
19268da3   Goutte   Initial commit.
1

5f63c83b   Goutte   Lint.
2
## http://heliopropa.irap.omp.eu
19268da3   Goutte   Initial commit.
3
4
5
6
7

# What

## Web Server

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


### Rationale

6b149919   Goutte   Add a Download bu...
15
16
- Reading NetCDF from javascript is doable, but still *very* hacky.
- The bridge can handle pagination and collecting multiple NetCDF into one CSV.
19268da3   Goutte   Initial commit.
17
18
19
20


# How

d08bc6bc   Goutte   Lint the README.
21
22
23
24
25
## Source

https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE


19268da3   Goutte   Initial commit.
26
27
28
29
## Overview

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


## Install

29551a9f   hitier   Update prerequisites
37
38
39
### Prerequisites
gcc
libncurses-dev
6a6d19ff   hitier   Update documentat...
40
41
42
python3
python3-virtualenv
libapache2-mod-wsgi-py3
29551a9f   hitier   Update prerequisites
43
44
45

### Python venv

19268da3   Goutte   Initial commit.
46
``` bash
1db3095f   hitier   Update dependencies
47
python3 -m venv venv
19268da3   Goutte   Initial commit.
48
source venv/bin/activate
f10f34d1   Goutte   More logic.
49
50
pip install matplotlib
pip install numpy==1.8.*
19268da3   Goutte   Initial commit.
51
52
53
pip install -r requirements.txt
```

f10f34d1   Goutte   More logic.
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
### CentOs 6 Shenanigans

``` bash
yum install https://centos6.iuscommunity.org/ius-release.rpm
yum install python27*
```

But then `virtualenv` yields

```
File "/var/www/html/HELIOPROPA/web/run.py", line 24, in <module>
[Fri Nov 30 14:30:38 2018] [error] [client 10.10.135.119]     from netCDF4 import Dataset, date2num
[Fri Nov 30 14:30:38 2018] [error] [client 10.10.135.119]   File "/var/www/html/HELIOPROPA/venv/lib/python2.7/site-packages/netCDF4/__init__.py", line 3, in <module>
[Fri Nov 30 14:30:38 2018] [error] [client 10.10.135.119]     from ._netCDF4 import *
[Fri Nov 30 14:30:38 2018] [error] [client 10.10.135.119] ImportError: /var/www/html/HELIOPROPA/venv/lib/python2.7/site-packages/netCDF4/_netCDF4.so: undefined symbol: PyUnicodeUCS2_FromStringAndSize
```

_Solution:_
Configure Apache to use `web/run_ssa.wsgi` and use pip2.7 install system wide.


### Install libcdf.

``` bash
29551a9f   hitier   Update prerequisites
78
79
80
wget https://spdf.gsfc.nasa.gov/pub/software/cdf/dist/cdf38_1/cdf38_1-dist-all.tar.gz
tar -xzvf cdf38_1-dist-all.tar.gz
cd cdf38_1-dist
f10f34d1   Goutte   More logic.
81
82
83
make all OS=linux ENV=gnu
make INSTALLDIR=/usr/local/lib/libcdf install
```
19268da3   Goutte   Initial commit.
84
85
86
87
88

## Develop

``` bash
source venv/bin/activate
206d8d14   Goutte   Clean up.
89
DEBUG=true python web/run.py
19268da3   Goutte   Initial commit.
90
91
92
```

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

d08bc6bc   Goutte   Lint the README.
94

5ef50583   Goutte   Clean up.
95
96
97
98
99
100
101
102
## Troubleshoot

### Installing scipy

Getting `MemoryErrors` ?
Try with the `--no-cache-dir` option.

`pip install scipy --no-cache-dir`
9c314ef2   Goutte   Add instructions ...
103
104
105
106
107
108

### Fix permissions problems with the cache

```
sudo setfacl  -R -m u:apache:rwx -m u:`whoami`:rwx cache
sudo setfacl -dR -m u:apache:rwx -m u:`whoami`:rwx cache
29551a9f   hitier   Update prerequisites
109
```
8cfeb607   hitier   More install and ...
110
111
112
113
114
115
116
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177

# Gunicorn and Nginx deployment on OVH for development

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


## wep app service and Gunicorn

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

## Nginx

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;
		}
	}


## Start and Allow at system reboot

	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