planb
planb copied to clipboard
Configuration to load enviroment variables with systemd
For Linux distro (in this case Ubuntu 16.04) that use the systemd, it worked when the file was written like this (Example: /etc/defaulft/planb)
PLANB_LISTEN=0.0.0.0:80
PLANB_READ_REDIS_HOST=redis.yourcompany.com
PLANB_READ_REDIS_PORT=6379
PLANB_WRITE_REDIS_HOST=redis.yourcompany.com
PLANB_WRITE_REDIS_PORT=6379
Instead of using in upstart:
PLANB_OPTS="--listen 0.0.0.0:80 --read-redis-host redis.yourcompany.com --read-redis-port 6379 --write-redis-host redis.yourcompany.com --write-redis-port 6379"
In the /etc/systemd/system/planb.service file, the line ExecStart=/usr/bin/planb, has been changed to:
ExecStart=/usr/bin/planb --listen ${PLANB_LISTEN} --read-redis-host "${PLANB_READ_REDIS_HOST}" --read-redis-port ${PLANB_READ_REDIS_PORT} --write-redis-host "${PLANB_WRITE_REDIS_HOST}" --write-redis-port ${PLANB_WRITE_REDIS_PORT}
Complete file:
[Unit]
Description=planb
[Service]
Type=simple
User=root
Group=root
# Load env vars from /etc/default/ and /etc/sysconfig/ if they exist.
# Prefixing the path with '-' makes it try to load, but if the file doesn't
# exist, it continues onward.
EnvironmentFile=-/etc/default/planb
ExecStart=/usr/bin/planb --listen ${PLANB_LISTEN} --read-redis-host "${PLANB_READ_REDIS_HOST}" --read-redis-port ${PLANB_READ_REDIS_PORT} --write-redis-host "${PLANB_WRITE_REDIS_HOST}" --write-redis-port ${PLANB_WRITE_REDIS_PORT}
Restart=always
WorkingDirectory=/
[Install]
WantedBy=multi-user.target