Using environment variables with PhotoStructure
You can use environment
variables to configure
PhotoStructure’s settings. The
defaults.env
file describes all of PhotoStructure’s settings, and how to change each with an
environment variable. This file will also be found in your root app directory
(from version 0.9.0 and later) if you’re using a PhotoStructure for
Servers edition.
Notes #
-
You can edit your
settings.toml
and set environment variables. -
Environment variables always override any values found in
settings.toml
. -
PhotoStructure only reads from
settings.toml
files. -
PhotoStructure does not read from a
defaults.env
file or.env
files. It’s up to you tosource
any environment variables into your shell.
Environment variable overrides and settings.toml values don’t mix #
PhotoStructure does not write environment variables overrides to your
settings.toml
files.
This is actually by design: previous versions of PhotoStructure didn’t
discriminate between settings.toml
values and environment variable overrides.
As an example, if you had set PS_LOG_LEVEL=debug
and then saved your settings
via the web UI, that debug
value would get persisted and become the new
default log level.
This behavior was surprising and confusing to most beta users. Thanks to the
principle of least
astonishment, we
decided that this was a “bug,” not a “feature,” and changed PhotoStructure to
keep environment variable overrides separated from values stored in the
settings.toml
files.
Converting between settings names and environment variable names #
To avoid name-colliding with other software, all PhotoStructure environment
variables are prefixed with PS_
and converted to UPPER_SNAKE_CASE
.
Examples #
-
The
PS_LOG_LEVEL
environment variable overrides thelogLevel
setting. -
The
PS_LIBRARY_PATH
environment variable overrides thelibraryPath
setting.
Caution: upgrades to your environment variables are not automatic #
When you upgrade to a new version of PhotoStructure, your prior settings.toml
files are automatically migrated to contain the settings (and defaults) of the
new version, while retaining your custom configurations.
We can’t do this for environment variables, though, as we don’t know where your environment variables are coming from, as they can be set in many different ways.
If you’re using environment variables, it’s up to you to review our release notes and make suitable settings changes when you upgrade. We mark any settings that are deleted, renamed, or have changed semantics with a đź’”.
It also might be helpful to look at differences between version tags on github.
How to set environment variables #
It’s up to you to copy, modify, and source the contents into the shell that starts your PhotoStructure process.
macOS (desktop) #
If you’re using PhotoStructure for Desktops on macOS, you can set environment variables with launchctl setenv
.
To disable video transcoding, for example, open a terminal and run:
launchctl setenv PS_TRANSCODE_VIDEOS false
To get the current value, use launchctl getenv
:
launchctl getenv PS_TRANSCODE_VIDEOS
To unset (and use PhotoStructure’s default), use launchctl unsetenv
:
launchctl unsetenv PS_TRANSCODE_VIDEOS
Linux and macOS (server) #
Add environment variables to the relevant rc script for your shell. If you’re using
bash, that’s ~/.profile
:
export PS_LOG_LEVEL=info
Windows #
- Hit the
Windows key, and type “environment”, - select “Edit the system environment vairables” control panel,
- click the
Environment Variables...
button in the bottom right, and - click
New...
Docker #
With docker, use the docker run
--env
option:
docker run docker run --name photostructure --env PS_LOG_LEVEL=info ...
With docker-compose, use the environment configuration option:
...
environment:
- "PS_LOG_LEVEL=info"
...