I'm using Fab to deploy my application. The running of my application depends on some environment variables set in $HOME/.bashrc. However when I use fab to run the application using the below command
run("java -jar app.jar")
This application does not run as expected because the environment variables like SMTP_HOST, SMTP_PORT I set in $HOME/.bashrc are not available for this application?
I have set the env variables in $HOME/.bashrc as below
export SMTP_PORT=abc
How do I ensure the environment variables are set before I execute the run() command to run the app?
You can find the following lines in .bashrc
:
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
that means fabric will never source code after that block, as fabric runs your command non-interactively (in form of /bin/bash -l -c some_command
)
so the simple workaround is moving export SMTP_PORT=abc
to .bash_profile
or .profile
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With