Posted about 1 year ago. Visible to the public.

Configuration of your application

In most cases your application needs configuration data like database endpoints or API keys to work. This section will help you find the correct location for your configuration data.

Ruby on Rails

There are multiple ways to configure your application.
The database configuration for your application is deliviered via our configuration management (which also configures your database). You can find it in /var/www/$deployment/shared/config/database.yml. Our capistrano sample recipe symlinks this configuration file during the deployment and your application should use this file by default.
Other configuration data should be stored in the directory shared/config too. It is synced between all your application servers and we will make daily backups of it. If you want us to deliver configuration files (like secrets.yml) for you just contact our operations team. We can deploy these files with our configuration management.

Environment variables

If your rails application expects configuration via environment variables you can place a shared/config/.env file. Environment variables can also be configured by our makandra operations team via our configuration management.

The application processes are invoked via bash so you will have all the variables written to this file available. See down below for more information.

Elixir / Phoenix

We place a database.exs file in the /var/www/$deployment/shared/config/ directory. You can use this file to build your application.
If you create a /var/www/$deployment/shared/config/.env file there will be some default environment variables with configuration for our hosting infrastructure:

  • DATABASE_URL: a database connection string like ecto://dbuser:password@127.0.0.1:false/dbname&pool_size=10
  • APPDIR: path to your application directory
  • PORT: the port your app must listen on

If you want to use environment variables to configure your application at runtime you can place them in /var/www/$deployment/shared/config/.env (see down below for further information). Please ensure that your application is started via bash. The environment variables are only read when the application is invoked via a bash shell.

PHP application

There is no default configuration scheme for PHP applications. Ask our operations team for the database credentials. If you want to configure your application via environment variables contact our operations team to configure the variables for you.

Invalidating the PHP cache

When you deploy a new version of your PHP application, the fpm-php workers will not restart and clear your opcache and apc. As you usually want to start using your newly deployed code immediately, we allow clearing the caches using the FPM socket.

We suggest installing and using cachetool for this. After installation you may use it from your capistrano/compose tasks or on the cli like this:

Copy
$ php cachetool.phar opcache:reset --fcgi=/var/run/php/$deployment-fpm.sock

Configuring your application via environment variables

Please mind that this is not working at the moment for PHP applications. If you want to pass environment variables to your PHP application contact the makandra operations team to configure it for you.

If your application expects configuration via environment variables you can place a /var/www/$deployment/shared/config/.env file which will be read by the deploy users .bashrc if present. The syntax must be in shell style like this:

Copy
# this is a comment and will be ignored FOO_API_KEY=lahj3987yagxg FACEBOOK=fb1UYGF1f7dJ # this comment will be ignored TWITTER=BLCJKJSLU^T!#@&^LC

Please mind that these environment variables will be loaded if you login with your user and from passenger (rails) processes but are not read by your cronjobs or elixir application by default! You need to prefix your cronjobs with source /var/www/$deployment/shared/config/.env && do_something or you should invoke your cronjob via bash bash -c 'do_something'. Your elixir application must be started via a bash shell.

Owner of this card:

Avatar
Claus-Theodor Riegg
Last edit:
27 days ago
by Stefan Langenmaier
Posted by Claus-Theodor Riegg to opscomplete
This website uses cookies to improve usability and analyze traffic.
Accept or learn more