ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Auto-restart service with Systemd

    IT Discussion
    systemd services linux
    3
    6
    1.3k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • stacksofplatesS
      stacksofplates
      last edited by stacksofplates

      I've used monit and supervisord previously to restart services that have been stopped. Systemd ships with this support natively. So if you want to make sure chronyd restarts you would do this:

      systemctl edit chronyd
      

      Then enter:

      [Service]
      
      Restart=always
      

      Then finally run:

      systemctl daemon-reload
      

      That's it. It stores a file under /etc/systemd/system/chronyd.service.d/ called overrides.conf with that exact text we entered above. This also means we can push this out with our CM tool.

      1 Reply Last reply Reply Quote 2
      • scottalanmillerS
        scottalanmiller
        last edited by

        I believe that this is set automatically with Salt if you use the "Restart=True" option for a service.

        stacksofplatesS 1 Reply Last reply Reply Quote 0
        • stacksofplatesS
          stacksofplates @scottalanmiller
          last edited by

          @scottalanmiller said in Auto-restart service with Systemd:

          I believe that this is set automatically with Salt if you use the "Restart=True" option for a service.

          I can't find that in the docs anywhere (at least in the past few mins).

          I don't think ansible can do this. At least it's not stated if it can.

          scottalanmillerS 1 Reply Last reply Reply Quote 0
          • scottalanmillerS
            scottalanmiller @stacksofplates
            last edited by

            @stacksofplates said in Auto-restart service with Systemd:

            @scottalanmiller said in Auto-restart service with Systemd:

            I believe that this is set automatically with Salt if you use the "Restart=True" option for a service.

            I can't find that in the docs anywhere (at least in the past few mins).

            I don't think ansible can do this. At least it's not stated if it can.

            I know that salt has the option. What mechanism it chooses I don't know.

            stacksofplatesS 1 Reply Last reply Reply Quote 0
            • stacksofplatesS
              stacksofplates @scottalanmiller
              last edited by

              @scottalanmiller said in Auto-restart service with Systemd:

              @stacksofplates said in Auto-restart service with Systemd:

              @scottalanmiller said in Auto-restart service with Systemd:

              I believe that this is set automatically with Salt if you use the "Restart=True" option for a service.

              I can't find that in the docs anywhere (at least in the past few mins).

              I don't think ansible can do this. At least it's not stated if it can.

              I know that salt has the option. What mechanism it chooses I don't know.

              Ya I wonder how it can do that. It would only be able to do it on a system that has systemd, and how it would handle something without it.

              Init can't do this, which is why monit and supervisord existed before.

              1 Reply Last reply Reply Quote 0
              • matteo nunziatiM
                matteo nunziati
                last edited by

                systemd has got this since early development. this, among other things (PID 1 master process...etc), was one of the reasons Poettering designed systemd. It borrowed this idea from other systems like this

                1 Reply Last reply Reply Quote 0
                • 1 / 1
                • First post
                  Last post