Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Configuration to load enviroment variables with systemd #41

Open
patrezze opened this issue Apr 27, 2018 · 0 comments
Open

Configuration to load enviroment variables with systemd #41

patrezze opened this issue Apr 27, 2018 · 0 comments

Comments

@patrezze
Copy link

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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant