These instructions are written for Ubuntu, and for the remote Oracle database server.
The instructions require that all user-specific (non-sudo) commands be executed by user created for running this service.
For example user pyha and group pyha.
Follow the steps below to install:
-
Download the following Oracle clients here:
- Oracle Instant Client Basic Linux 12.1.0.2.0
- Instant Client SDK Linux 12.1.0.2.0
-
Extract the archives (they will be extracted to the same folder). Then add the following lines to the file
~/.bashrc:export ORACLE_HOME=path/to/instantclient_12_1 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME
Enter to a terminal:
source ~/.bashrc
or restart the terminal for the
~/.bashrcinstalled environment variables to take effect. -
Then do the following:
cd path/to/instantclient_12_1
ln -s libclntsh.so.12.1 libclntsh.so ln -s libocci.so.12.1 libocci.so
Install the following packages
sudo apt-get install && sudo apt-get update
sudo apt-get install build-essential python3 python-pip python3-pip python-virtualenv git libaio1Create a folder where you plan to install the environment and clone the pyha repository in it:
mkdir ~/pyhaNavigate to the folder
cd ~/pyhaclone repository:
git clone https://bitbucket.org/luomus/pyha.git
Navigate to the created folder called pyha:
cd pyhaMake sure that all cloned files and the pyha folder have the rights of the user created for the pyha system,
as well as the execution rights of the shell scripts (*.sh files).
chmod u+x *.shRun the script created for automatic installation:
./install.shIf the automatic installation was successful, you can skip step 4.
The following line creates a new virtualenv environment with python 3 in its own folder env:
virtualenv -p python3 envOpen the python virtual environment:
source env/bin/activateInstall the programs required by the python virtual environment:
pip install -r Requirements.txtand / or
pip3 install -r Requirements.txtCreate a file:
touch env_variables.shAdd all environment variables there (see the list of variables with examples in the install.sh file):
export ENVAR='content'
...
export ENVARx-1='contentx-1'
export ENVARx='contentx'
ENVAR Names are listed in the KEYS variable, as well as the correct type of content values in the string commenting on the ENVAR variable name.
If step 3 was successful, you can transfer the files:
pyha.service
pyha.socket
from the services folder to the /etc/systemd/system service folder.
If you use the pyha service via Apache at: hostdomain / pyha, put:
services/pyha.conf in folder /etc/httpd/conf.d/.
Add services/pyha.cron to the user's crontab file directory (usually /var/spool/cron) for scheduled functionality,
or preferably edit the user's crontab file with the command below and add the pyha.cron file's content.
crontab -eIf step 3 was not successful, create a file (pyha.service):
/etc/systemd/system/pyha.service
with contents:
[Unit]
Description=pyha
Requires=pyha.socket
After=network.target
[Service]
PIDFile=/run/pyha/pid
User=pyha
Group=pyha
WorkingDirectory=<path/to/folder/pyha project>
Environment=ENVAR='content'
...
Environment=ENVARx='contentx'
ExecStart=path/to/folder/env/bin/gunicorn --threads 3 --timeout 600 --pid /run/pyha/pid wsgi
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
Create another file (pyha.socket):
/etc/systemd/system/pyha.socket
with contents:
[Unit]
Description=pyha socket
[Socket]
ListenStream=/run/pyha/socket
[Install]
WantedBy=sockets.target
If you use Apache webserver with: 'hostdomain/pyha', create a file:
/etc/httpd/conf.d/pyha.conf
with the following contents:
#Pyha
<Directory "path/to/project/static">
AllowOverride None
Require all granted
</Directory>
ProxyPass /pyha/static !
ProxyPass /pyha http://localhost:port
ProxyPassReverse /pyha http://localhost:port
Alias /pyha/static path/to/project/static
The timers work as internal threads, so there is no need to use crontab.
Make sure that all of the above files and the pyha folder have the rights of the user created for the pyha system,
as well as the permissions on the shell scripts (*.sh) files.
For example, for the user pyha and the group pyha.