From 29866d5689c7388cfc1f8f0af4ff08761b7a2b25 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Mon, 15 Apr 2019 12:31:54 +0100 Subject: [PATCH] Update setup for CentOS 7. --- INSTALL.md | 31 +++++++++++++++++++++---------- config/findingchart.conf | 16 ---------------- config/findingchart.ini | 15 --------------- findingchart.ini | 12 ++++++++++++ findingchart.service | 14 ++++++++++++++ 5 files changed, 47 insertions(+), 41 deletions(-) delete mode 100644 config/findingchart.conf delete mode 100644 config/findingchart.ini create mode 100644 findingchart.ini create mode 100644 findingchart.service diff --git a/INSTALL.md b/INSTALL.md index a1b819c..e1dbfc8 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -1,18 +1,29 @@ -##### Notes for deploying on OpenSUSE +##### Notes for deploying on CentOS 7 -Install nginx, uwsgi, uwsgi-python3 packages (need server repo enabled). +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 /srv/findingchart/appdata/ and chown -R nginx:nginx -Move config/findingchart.ini to /etc/uwsgi/vassals/ (uWSGI Emperor config file) -Move config/findingchart.conf to /etc/nginx/conf.d/ (nginx config file) +Clone the repository to a useful location and edit `findingchart.service` to point to it +Copy `findingchart.service` to `/usr/lib/systemd/system/` -Open port 80 in the firewall by setting `FW_SERVICES_EXT_TCP="80"` in /etc/sysconfig/SuSEfirewall2 +Create a directory `/srv/sockets` and `chown nginx:nginx` it. -Enable and start services +Enable and start the `findingchart` service. +Add to the nginx config ``` -systemctl enable nginx uwsgi -systemctl start nginx uwsgi -systemctl restart SuSEfirewall2 +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 diff --git a/config/findingchart.conf b/config/findingchart.conf deleted file mode 100644 index 02ee813..0000000 --- a/config/findingchart.conf +++ /dev/null @@ -1,16 +0,0 @@ -server { - listen 80; - server_name _, localhost; - - location = /findingchart { rewrite ^ /findingchart/; } - - location /findingchart/static { - alias /srv/findingchart/appdata/static; - } - - location /findingchart/ { - uwsgi_pass unix:/srv/findingchart/uwsgi.sock; - uwsgi_param SCRIPT_NAME /findingchart; - include uwsgi_params; - } -} diff --git a/config/findingchart.ini b/config/findingchart.ini deleted file mode 100644 index 404b383..0000000 --- a/config/findingchart.ini +++ /dev/null @@ -1,15 +0,0 @@ -[uwsgi] -socket = /srv/findingchart/uwsgi.sock -chmod-socket = 775 -chdir = /srv/findingchart/appdata -master = true -mount = /findingchart=findingchart.py -callable = app -uid = nginx -gid = nginx -processes = 1 -threads = 1 -plugins = python3,logfile -logger = file:/srv/findingchart/uwsgi.log -manage-script-name = true - diff --git a/findingchart.ini b/findingchart.ini new file mode 100644 index 0000000..ada64e3 --- /dev/null +++ b/findingchart.ini @@ -0,0 +1,12 @@ +[uwsgi] +socket = /srv/sockets/findingchart.sock +master = true +mount = /findingchart=findingchart.py +callable = app +uid = nginx +gid = nginx +processes = 1 +threads = 1 +plugins = python36 +manage-script-name = true + diff --git a/findingchart.service b/findingchart.service new file mode 100644 index 0000000..086177c --- /dev/null +++ b/findingchart.service @@ -0,0 +1,14 @@ +[Unit] +Description=uWSGI server for Finding Chart generator +After=network.target + +[Service] +User=nginx +Group=nginx +WorkingDirectory={{PROJECT_DIR}}} +ExecStart=/usr/sbin/uwsgi --ini findingchart.ini +ExecReload=/bin/kill -HUP $MAINPID +KillSignal=SIGINT + +[Install] +WantedBy=multi-user.target