Update update_launch_autosubmit_API.sh
-
mentioned in issue #24 (closed)
-
Developer
I've tried to execute it at the VM and I think the script won't execute gunicorn because we're using the prod server venv path
[root@vm development]# source /srv/www/htdocs/AutosubmitAPI/venv27/bin/activate bash: /srv/www/htdocs/AutosubmitAPI/venv27/bin/activate: No such file or directory
Instead it should be the following:
[root@vm development]# source /var/www/html/autosubmitapi/venv27/bin/activate bash: /srv/www/htdocs/AutosubmitAPI/venv27/bin/activate: No such file or directory
I've already made the changes in the VM's script
-
Maintainer
we can pass the path to the virtual environment as parameter
-
Author Owner
I also added the
kill gunicorn
lines to the VM script, they weren't there. -
Maintainer
I will add the parameter with the virtual env path
-
Maintainer
new call will be as follows:
./update_launch_autosubmit_API.sh <path_to_env> | --update [OPT]
examples:
./update_launch_autosubmit_API.sh /var/www/html/autosubmitapi/venv27/bin/activate ./update_launch_autosubmit_API.sh /var/www/html/autosubmitapi/venv27/bin/activate --update
-
Author Owner
Can you set the path in an environment variable (in the .bashrc) and use it in the script? And allow the script to override the variable.
As it is getting more complex, you can use Bash
getopts
, and define the following options:-e to set the Python virtual env path -u to do the update
The Python ve default path would be the one defined in the environment variable defined in the .bashrc.
This will make it easier to run the script out of the
crontab
.For example:
PVE=$PVE_PATH # PVE_PATH is an env var defined in the .bashrc UPDATE=false while getopts ":e:u" opt; do case "$opt" in e) PVE=$OPTARG ;; u) UPDATE=true ;; esac if [ "$UPDATE" = true ]; then ....
I didn't check the code...
-
Maintainer
crontab en la VM:
@reboot /home/rocky/development/update_launch_AS_API.sh var/www/html/autosubmitapi/venv27/bin/activate
crontab en prod:
@reboot /home/webadmin/update_launch_AS_API.sh /srv/www/htdocs/AutosubmitAPI/venv27/bin/activate
I tested only in dev environment
-
Author Owner
Yes, it's user-specific, but we are all using
root
to launch the API (it's in root's crontab and you can only kill root's processes if you are root).So putting the env var in root's .bashrc (webadmin in production) in the VM should work.
-
Author Owner
This is to not have to remember the path everytime (that is different in both systems) to re-launch the system in case of emergency.
-
Maintainer
I applied the changes to all environments, I did not test in production to avoid causing disruptions