Using setting from an external file in a systemd service in Ubuntu 22.04

Viewed 12
ubuntu 22.04

I am setting up a systemd service, and would like to generalize it, so I would not have to edit the service for various deployment environments.

The service file, will have the following statement int it:

[Service]
....
ExecStart=/bin/bash -lc 'exec /home/deploy/.rbenv/shims/bundle exec sidekiq - e production'

This means I have to edit the service file, for various deployment environments. Is there a way I can replace 'production' with a variable I get from a specific user's environment?

It is an environment variable set in:

/home/deploy/.bashrc
  ...
  export RAILS_ENV=test

But that's in the deploy user space, so the the system service does not know about it.

Any ideas?

0 Answers
Related