Runtime parameters for a systemd service

19,819

The EnvironmentFile option should be set to the full path of the file containing any necessary environment variables needed for proper operation of the executable. See EnvironmentFile in man systemd.exec for details.

Arguments to the executable can be included in the "ExecStart" parameter. This mechanic is separate and distinct from the "EnvironmentFile" option. You can find more documentation at http://www.freedesktop.org/software/systemd/man/systemd.service.html

Share:
19,819

Related videos on Youtube

f1rstsurf
Author by

f1rstsurf

Quite frankly, even if the choice of C were to do nothing but keep the C++ programmers out, that in itself would be a huge reason to use C. In other words: the choice of C is the only sane choice. I know Miles Bader jokingly said "to piss you off", but it's actually true. I've come to the conclusion that any programmer that would prefer the project to be in C++ over C is likely a programmer that I really would prefer to piss off, so that he doesn't come and screw up any project I'm involved with. The only way to do good, efficient, and system-level and portable C++ ends up to limit yourself to all the things that are basically available in C. And limiting your project to C means that people don't screw that up, and also means that you get a lot of programmers that do actually understand low-level issues and don't screw things up with any idiotic "object model" crap. So I'm sorry, but for something like git, where efficiency was a primary objective, the "advantages" of C++ is just a huge mistake. The fact that we also piss off people who cannot see that is just a big additional advantage. -- Linus Torvalds

Updated on September 18, 2022

Comments

  • f1rstsurf
    f1rstsurf over 1 year

    I am a little confused about how runtime parameters are normally supplied to a systemd service. The general idea I have is that the following happens:

    There is a file that contains the environment variable settings, e.g., /etc/sysconfig/mydaemon

    Then there is the unit file, e.g., mydaemon.service (not sure where this is located)

    Inside of the unit file is a line such as the following:

    EnvironmentFile=-/etc/sysconfig/mydaemon
    

    When the service is started, the settings file is opened then each setting is supplied to main as argc/argv. Is that right?

    • eyoung100
      eyoung100 over 9 years
      See this blog post for a start. A service file doesn't accept arguments to my knowledge. You must pass the service file variable options contained in the file referenced by the EnvironmentFile
    • f1rstsurf
      f1rstsurf over 9 years
      I did actually read that blog before I posted. It does not make everything clear. For example, it does no explain how the service code accesses the options settings, among other things.
    • f1rstsurf
      f1rstsurf over 9 years
      Also, just as an aside, why is there a dash in the EnvironmentFile setting shown above?
    • eyoung100
      eyoung100 over 9 years
      Look at the section under Configuration. That file snippet is a plain .conf file stored in /etc You can write to and store variables in that file then pass the filename in the EnvironmentFile line. To actually pass the values use the ExecFile line and pass the options through string expansion.
    • eyoung100
      eyoung100 over 9 years
      Re: Dash. From the systemd.exec man page: The argument passed should be an absolute filename or wildcard expression, optionally prefixed with "-", which indicates that if the file does not exist, it will not be read and no error or warning message is logged.