Commit a6090acb authored by Miguel Castrillo's avatar Miguel Castrillo
Browse files

Update update_launch_autosubmit_API.sh

parent 7579eaf2
  • mentioned in issue #24 (closed)

    Toggle commit list
  • 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

  • Thanks @cgutierr, you mean in the Dev. VM right? I tested this one in the production machine.

    @jberlin I guess you didn't test the script in the VM?

  • @mcastril yes, all of this has been done in the dev VM.

  • Hi @mcastril , no I did not tested it. I thought the virtual dev env was set elsewhere and not in the script

  • we can pass the path to the virtual environment as parameter

  • I also added the kill gunicorn lines to the VM script, they weren't there.

  • I will add the parameter with the virtual env path

  • 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
    Edited by jberlin
  • 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...

    Edited by Miguel Castrillo
  • 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

    Edited by jberlin
  • Hi @mcastril , I will have a look to your idea, but isnt .bashrc user specific ? I think it can cause more dependence on the user. but I will have a look anyways.

  • 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.

  • 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.

  • Hi @mcastril , I applied your idea in dev environment and it works

  • I applied the changes to all environments, I did not test in production to avoid causing disruptions

  • Perfect @jberlin

    Tested in production now. It works.

Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment