问题
How can I persist environment variables for my Rails app hosted on Digital Ocean?
Locally I run a bash script with commands like, export SERVICE_USERNAME='somekey'
.
But when I try to manually run export SERVICE_USERNAME='somekey'
, while ssh-ing onto the Ubuntu server, they only last for the session... which is not helpful for my app.
How can I persist environment variables on Digital Ocean? Is there a simple way?
回答1:
You can either set your environment variables to the user (in the ~/.profile or ~./pam_environment files of the user) or system wide (in the /etc/environment file)
You can find more info on this Ubuntu documentation.
EDIT;
You could have your script to do this:
sudo echo 'export SERVICE_USERNAME="somekey"' >> /etc/environment
来源:https://stackoverflow.com/questions/42615522/persist-environment-variable-for-a-rails-app-on-digital-ocean