Aponte systemctl para usar variáveis ​​de um arquivo

Aponte systemctl para usar variáveis ​​de um arquivo

Estou usando systemctlpara iniciar e manter meu aplicativo ativo. Abaixo está meu .servicearquivo. Observe o Environment='METEOR_SETTINGS={"privateKey": "ohnoyouseemyprivatekey!"}'. É aqui que armazenarei as chaves privadas e desejo não colocá-las visíveis neste local.

Minha pergunta é: como exatamente peço ao systemctl para lê-lo de um arquivo em um local específico em

[Service]
ExecStart=/usr/bin/node /home/wow-doge/experimental/wow_doge_builds/bundle/main.js
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=logdoge
#User=root
#Group=root
Environment=NODE_ENV=production
Environment=PORT=3000
Environment=HTTP_FORWARDED_COUNT=1
Environment=MONGO_URL=mongodb://127.0.0.1:27017/wow-doge
Environment=ROOT_URL=https://localhost
Environment='METEOR_SETTINGS={"privateKey": "ohnoyouseemyprivatekey!"}'

[Install]
WantedBy=multi-user.target

Responder1

Tirado dehttps://coreos.com/os/docs/latest/using-environment-variables-in-systemd-units.html#environmentfile-directive

EnvironmentFile semelhante à diretiva Environment, mas lê as variáveis ​​de ambiente de um arquivo de texto. O arquivo de texto deve conter atribuições de variáveis ​​separadas por nova linha.

Exemplo:

[Service]
EnvironmentFile=/etc/envfile

Conteúdo de /etc/envfile:

NODE_ENV=production
PORT=3000
HTTP_FORWARDED_COUNT=1
MONGO_URL=mongodb://127.0.0.1:27017/wow-doge
ROOT_URL=https://localhost
METEOR_SETTINGS={"privateKey": "ohnoyouseemyprivatekey!"}

informação relacionada