From 87693d827a2e81e26b16676f062b7f3045c6e7aa Mon Sep 17 00:00:00 2001 From: Ram Gupta Date: Sat, 26 Jan 2019 17:55:58 -0600 Subject: [PATCH] install.sh: Added install script Added install script which 1. Copies source files to /srv 2. Installs python and dependecies in a venv 3. Copies and sets up the systemd file and service 4. Launches the systemd service --- broadway-on-demand.service | 13 +++++++++++++ install.sh | 31 +++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 broadway-on-demand.service create mode 100755 install.sh diff --git a/broadway-on-demand.service b/broadway-on-demand.service new file mode 100644 index 0000000..629c1ee --- /dev/null +++ b/broadway-on-demand.service @@ -0,0 +1,13 @@ +[Unit] +Description=Gunicorn for Broadway on Demand +After=network.target + +[Service] +User=root +Group=root +WorkingDirectory=/srv/broadway-on-demand +Environment=/srv/broadway-on-demand/src/venv/bin +ExecStart=/srv/broadway-on-demand/src/venv/bin/gunicorn --workers 4 --bind 127.0.0.1:4000 src:app + +[Install] +WantedBy=multi-user.target diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..97081cd --- /dev/null +++ b/install.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# NEED TO RUN AS ROOT + +INSTALL_DIR="/srv" +VENV_NAME="venv" + +# Install python and related packages +apt-get install python3 python3-venv + +# Default location for broadway-on-demand is /srv +cp -r . $INSTALL_DIR/broadway-on-demand/ +cd $INSTALL_DIR/broadway-on-demand/ + +# Setup venv +cd src/ +python3 -m venv ./$VENV_NAME +source ./$VENV_NAME/bin/activate + +# Install python dependencies +python3 -m pip install -r requirements.txt +python3 -m pip install gunicorn + +# Setup config file +# CHANGE THIS +# cp sample_config.py config.py + +# Setup systemd service +cd .. +cp broadway-on-demand.service /etc/systemd/system/ +systemctl enable broadway-on-demand +systemctl start broadway-on-demand