From 760f8d329233b51d7a31f091b6ed6928da5604fd Mon Sep 17 00:00:00 2001
From: Paul Chote
Date: Tue, 18 Feb 2020 12:03:59 +0000
Subject: [PATCH] Update setup for CentOS 8.
---
INSTALL.md | 64 ++++++++++++++++++++++++--------------------
findingchart.ini | 7 +++--
findingchart.py | 1 +
findingchart.service | 6 ++---
4 files changed, 42 insertions(+), 36 deletions(-)
diff --git a/INSTALL.md b/INSTALL.md
index e1dbfc8..98afd93 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -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`
\ No newline at end of file
+##### 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 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 /static;
+ }
+
+ location /findingchart/ {
+ uwsgi_pass unix:/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`
+ ```
diff --git a/findingchart.ini b/findingchart.ini
index ada64e3..1a1c97c 100644
--- a/findingchart.ini
+++ b/findingchart.ini
@@ -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
-
diff --git a/findingchart.py b/findingchart.py
index 34e9ed4..42d8938 100644
--- a/findingchart.py
+++ b/findingchart.py
@@ -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
diff --git a/findingchart.service b/findingchart.service
index 086177c..7575721 100644
--- a/findingchart.service
+++ b/findingchart.service
@@ -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