Skip to content

Commit

Permalink
Update setup for CentOS 8.
Browse files Browse the repository at this point in the history
  • Loading branch information
pchote committed Feb 18, 2020
1 parent 29866d5 commit 760f8d3
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 36 deletions.
64 changes: 35 additions & 29 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,35 @@
##### Notes for deploying on CentOS 7

Add the `epel` repository and install the `nginx`, `uwsgi`, `uwsgi-python36` packages.
Install the python dependencies `python36-numpy`, `python36-Pillow`, `python36-Flask`, `python36-sep`

Clone the repository to a useful location and edit `findingchart.service` to point to it
Copy `findingchart.service` to `/usr/lib/systemd/system/`

Create a directory `/srv/sockets` and `chown nginx:nginx` it.

Enable and start the `findingchart` service.

Add to the nginx config
```
location = /findingchart { rewrite ^ /findingchart/; }
location /findingchart/static {
alias {{PROJECT_PATH}}/static;
}
location /findingchart/ {
uwsgi_pass unix:/srv/sockets/findingchart.sock;
uwsgi_param SCRIPT_NAME /findingchart;
include uwsgi_params;
}
```

Enable and start the `nginx` service.
Open the firewall if needed `sudo firewall-cmd --permanent --zone=public --add-service=http && sudo firewall-cmd --reload`
##### Notes for deploying on CentOS 8

1. Install dependencies: `nginx`, `uwsgi` (python), `flask` (python), `github-flask` (python), `numpy` (python), `sep` (python), `pillow` (python)
2. Clone the repository to a useful location
3. Edit `findingchart.ini` to set `uid = ` your username
4. Edit `findingchart.service` to point to set
* `User=` your username
* `WorkingDirectory=` project location

5. Copy `findingchart.service` to `/usr/lib/systemd/system/`
6. Add user to the `nginx` group: `sudo usermod -a -G <user> nginx`
7. `chmod g+x` each directory in the path to the project
8. Enable and start the service
```
sudo systemctl start findingchart
sudo systemctl enable findingchart
```
9. Create / update nginx config to include:
```
location /findingchart/static {
alias <project path>/static;
}
location /findingchart/ {
uwsgi_pass unix:<project path>/findingchart.sock;
uwsgi_param SCRIPT_NAME /findingchart;
include uwsgi_params;
}
```
10. Enable and start the `nginx` service.
11. Open the firewall if needed
```
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --reload`
```
7 changes: 3 additions & 4 deletions findingchart.ini
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
[uwsgi]
socket = /srv/sockets/findingchart.sock
socket = findingchart.sock
chmod-socket=664
master = true
mount = /findingchart=findingchart.py
callable = app
uid = nginx
uid = {{USER}}
gid = nginx
processes = 1
threads = 1
plugins = python36
manage-script-name = true

1 change: 1 addition & 0 deletions findingchart.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ def sexagesimal(angle):
degrees *= -1

return '{:d}:{:02d}:{:05.2f}'.format(degrees, minutes, seconds)

def offset_proper_motion(ra_degrees, dec_degrees, pm_ra_degrees, pm_dec_degrees, delta_yr):
ra = ra_degrees + float(pm_ra_degrees) / math.cos(dec_degrees * math.pi / 180) * delta_yr
dec = dec_degrees + float(pm_dec_degrees) * delta_yr
Expand Down
6 changes: 3 additions & 3 deletions findingchart.service
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ Description=uWSGI server for Finding Chart generator
After=network.target

[Service]
User=nginx
User={{USER}}
Group=nginx
WorkingDirectory={{PROJECT_DIR}}}
ExecStart=/usr/sbin/uwsgi --ini findingchart.ini
WorkingDirectory={{PROJECT_DIR}}
ExecStart=/usr/local/bin/uwsgi --ini findingchart.ini
ExecReload=/bin/kill -HUP $MAINPID
KillSignal=SIGINT

Expand Down

0 comments on commit 760f8d3

Please sign in to comment.