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

Configuration to load enviroment variables with systemd #41

@patrezze

Description

@patrezze

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions