Can systemd 'adopt' or 'inherit' a process or cgroup?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












I have a service that I would like to manage through systemd - let's call it foo. I wrote unit files, and they're working just fine. So, if I run systemctl start foo, the service starts correctly, and I can see its status with systemctl status foo.



However, an external program may also start the service, and it doesn't use systemd to start the service. So, the service can be running, but since it wasn't started through systemd, systemd doesn't know about it. In this case, systemctl status foo reports that the service has failed, even though its running correctly.



Is there a way to have systemd 'inherit' or 'adopt' this service, so systemctl status foo correctly reports that the service is running, even when systemd didn't start it? With SysV, I would write a small 'status' script, so I could /etc/init.d/foo status, but that doesn't seem to fit with the systemd model.



To be clear, when the external program starts the service, the service's processes are still children of PID 1/systemd. But, systemd doesn't recognize them as part of service foo, since systemd didn't start and register them.



The specific technologies are:



  • Oracle WebLogic (the service is a Managed WebLogic Instance)

  • Oracle NodeManager (this is the external program that may also start the service)

  • systemd 219









share|improve this question



























    up vote
    1
    down vote

    favorite












    I have a service that I would like to manage through systemd - let's call it foo. I wrote unit files, and they're working just fine. So, if I run systemctl start foo, the service starts correctly, and I can see its status with systemctl status foo.



    However, an external program may also start the service, and it doesn't use systemd to start the service. So, the service can be running, but since it wasn't started through systemd, systemd doesn't know about it. In this case, systemctl status foo reports that the service has failed, even though its running correctly.



    Is there a way to have systemd 'inherit' or 'adopt' this service, so systemctl status foo correctly reports that the service is running, even when systemd didn't start it? With SysV, I would write a small 'status' script, so I could /etc/init.d/foo status, but that doesn't seem to fit with the systemd model.



    To be clear, when the external program starts the service, the service's processes are still children of PID 1/systemd. But, systemd doesn't recognize them as part of service foo, since systemd didn't start and register them.



    The specific technologies are:



    • Oracle WebLogic (the service is a Managed WebLogic Instance)

    • Oracle NodeManager (this is the external program that may also start the service)

    • systemd 219









    share|improve this question

























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I have a service that I would like to manage through systemd - let's call it foo. I wrote unit files, and they're working just fine. So, if I run systemctl start foo, the service starts correctly, and I can see its status with systemctl status foo.



      However, an external program may also start the service, and it doesn't use systemd to start the service. So, the service can be running, but since it wasn't started through systemd, systemd doesn't know about it. In this case, systemctl status foo reports that the service has failed, even though its running correctly.



      Is there a way to have systemd 'inherit' or 'adopt' this service, so systemctl status foo correctly reports that the service is running, even when systemd didn't start it? With SysV, I would write a small 'status' script, so I could /etc/init.d/foo status, but that doesn't seem to fit with the systemd model.



      To be clear, when the external program starts the service, the service's processes are still children of PID 1/systemd. But, systemd doesn't recognize them as part of service foo, since systemd didn't start and register them.



      The specific technologies are:



      • Oracle WebLogic (the service is a Managed WebLogic Instance)

      • Oracle NodeManager (this is the external program that may also start the service)

      • systemd 219









      share|improve this question















      I have a service that I would like to manage through systemd - let's call it foo. I wrote unit files, and they're working just fine. So, if I run systemctl start foo, the service starts correctly, and I can see its status with systemctl status foo.



      However, an external program may also start the service, and it doesn't use systemd to start the service. So, the service can be running, but since it wasn't started through systemd, systemd doesn't know about it. In this case, systemctl status foo reports that the service has failed, even though its running correctly.



      Is there a way to have systemd 'inherit' or 'adopt' this service, so systemctl status foo correctly reports that the service is running, even when systemd didn't start it? With SysV, I would write a small 'status' script, so I could /etc/init.d/foo status, but that doesn't seem to fit with the systemd model.



      To be clear, when the external program starts the service, the service's processes are still children of PID 1/systemd. But, systemd doesn't recognize them as part of service foo, since systemd didn't start and register them.



      The specific technologies are:



      • Oracle WebLogic (the service is a Managed WebLogic Instance)

      • Oracle NodeManager (this is the external program that may also start the service)

      • systemd 219






      systemd oracle-linux systemctl






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited yesterday









      Rui F Ribeiro

      38.1k1475123




      38.1k1475123










      asked yesterday









      Grant Gordon

      84




      84




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          No. The process will be running in a different context as far as systemd is concerned.



          This is, in fact, one of the reasons that Desktop Bus service activation should be avoided. Service processes directly spawned by the Desktop Bus broker are part of its service, as far as systemd is concerned.



          One can move processes amongst control groups, with appropriate privileges. But this is only half of the job, and the other half, that of convincing systemd that it started a unit when it did not and rewriting the necessary parts of its internal data structures, is not provided for.



          This is not only not systemd's model, it is not the model of most service management subsystems.



          Far too many people's "just fine" service units for Oracle softwares actually are not, by the way, and are in House of Horror territory.



          Further reading



          • systemctl fails to accurately report status of daemons if they were started via mechanism other than systemctl

          • configure java daemon with systemd

          • https://unix.stackexchange.com/a/437461/5132

          • Jonathan de Boyne Pollard (2016). Avoid Desktop Bus (D-Bus) bus activation
            . nosh. Softwares.

          • Jonathan de Boyne Pollard (2015). The systemd House of Horror. Frequently Given Answers.





          share|improve this answer




















          • Your comments on D-Bus activation are on point, but only when activation happens at the dbus-daemon. As your separate article points out, when systemd is involved, things work fine. So D-Bus activation with systemd (which is done with service units having Type=dbus) should be perfectly fine, and doesn't suffer from the problems you describe. Given upstart is mostly gone at this point, I think it's important to point out or clarify the context of those problems with D-Bus activation. They were more relevant in the past, before Debian/Ubuntu switched to systemd by default.
            – Filipe Brandenburger
            yesterday










          • The problem continues to be as relevant now as it was. It is a misrepresentation (another mis-application of "fine" indeed) to say that systemd has somehow cured this. If the problem weren't relevant any more, the idiosyncratic and tightly coupled communications channel between the broker and systemd would no longer be needed. It of course still is needed, with the context that broker-spawned processes run in continuing unabated to be problematic, and the fact that it is idiosyncratic and too strongly coupled continues to be the part of the problem that the Upstart people identified it as.
            – JdeBP
            yesterday










          • Thank you! I appreciate all the documentation - I was worried that this might be the case, but it's good to be able to point to references. "Don't ask me why, so far, all of these have involved starting Java programs. Maybe it's Oracle in general." hits too close to home, haha.
            – Grant Gordon
            yesterday











          • hmm is there a little weirdness exec'ing service because it's not what you want with the old sysvinits ? you don't want a sysvinit service for a dbus-activatable service, because running service can return failure if it races with someone else, right? I guess the ol' service API wants tightening up a bit first?
            – sourcejedi
            yesterday


















          up vote
          0
          down vote













          In short, there isn't a way to have systemd consider a service to be started unless it was started by systemd itself. One of the main points of systemd is consistency in managing services and having separate ways to start a service goes against that idea.



          Now, systemd does have a provision to manage processes that are started externally, which seems to be somewhat suitable for the case you describe. That's actually a separate kind of unit, a scope unit.



          Using a scope unit still requires your external system to interact with systemd, since a scope unit can only be started with a D-Bus request to systemd, in which a PID is passed which is used as the initial process in the scope. Also, when a scope unit is started, systemd still wants to create the cgroups itself (it will then move the passed PID into the created cgroups.) So, this needs support from the application creating new processes, if it wants systemd to manage those as a scope.



          In short, avoid having two separate ways to start a service. If you need to use the third party service manager, use only that.



          If the issue you are trying to solve is to start the service during boot up, then:



          1. Check if your third party manager (in your case, Oracle NodeManager) supports configuring services during boot up. As it's managing the service, it should manage service during boot up as well.


          2. If you get systemd involved, then use a simple oneshot service unit that simply requests the third party manager to start the service. This means contacting the third party manager (in your case, Oracle NodeManager) through an API or RPC of some kind, maybe through HTTP, and telling it to start the service.


          If you use the systemd oneshot for startup, then name your unit appropriately (like "start-foo" or "initial-foo" or "foo-startup") to make it clear it won't stay "up", and keep RemainAfterExit= as no (the default) so checking the status on that unit will just say it's finished successfully, so there's no confusion about it reflecting the status of the service running under the third party manager.






          share|improve this answer






















          • I foresee people reading this and running startNodeManager.sh as a oneshot service. They even have the likes of stackoverflow.com/questions/30640717 for bodges to pile on when it does not work. More House of Horror stuff. (-:
            – JdeBP
            yesterday










          • @JdeBP Rephrased that last part to make that more clear, please take a look.
            – Filipe Brandenburger
            15 hours ago










          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f481535%2fcan-systemd-adopt-or-inherit-a-process-or-cgroup%23new-answer', 'question_page');

          );

          Post as a guest






























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          1
          down vote



          accepted










          No. The process will be running in a different context as far as systemd is concerned.



          This is, in fact, one of the reasons that Desktop Bus service activation should be avoided. Service processes directly spawned by the Desktop Bus broker are part of its service, as far as systemd is concerned.



          One can move processes amongst control groups, with appropriate privileges. But this is only half of the job, and the other half, that of convincing systemd that it started a unit when it did not and rewriting the necessary parts of its internal data structures, is not provided for.



          This is not only not systemd's model, it is not the model of most service management subsystems.



          Far too many people's "just fine" service units for Oracle softwares actually are not, by the way, and are in House of Horror territory.



          Further reading



          • systemctl fails to accurately report status of daemons if they were started via mechanism other than systemctl

          • configure java daemon with systemd

          • https://unix.stackexchange.com/a/437461/5132

          • Jonathan de Boyne Pollard (2016). Avoid Desktop Bus (D-Bus) bus activation
            . nosh. Softwares.

          • Jonathan de Boyne Pollard (2015). The systemd House of Horror. Frequently Given Answers.





          share|improve this answer




















          • Your comments on D-Bus activation are on point, but only when activation happens at the dbus-daemon. As your separate article points out, when systemd is involved, things work fine. So D-Bus activation with systemd (which is done with service units having Type=dbus) should be perfectly fine, and doesn't suffer from the problems you describe. Given upstart is mostly gone at this point, I think it's important to point out or clarify the context of those problems with D-Bus activation. They were more relevant in the past, before Debian/Ubuntu switched to systemd by default.
            – Filipe Brandenburger
            yesterday










          • The problem continues to be as relevant now as it was. It is a misrepresentation (another mis-application of "fine" indeed) to say that systemd has somehow cured this. If the problem weren't relevant any more, the idiosyncratic and tightly coupled communications channel between the broker and systemd would no longer be needed. It of course still is needed, with the context that broker-spawned processes run in continuing unabated to be problematic, and the fact that it is idiosyncratic and too strongly coupled continues to be the part of the problem that the Upstart people identified it as.
            – JdeBP
            yesterday










          • Thank you! I appreciate all the documentation - I was worried that this might be the case, but it's good to be able to point to references. "Don't ask me why, so far, all of these have involved starting Java programs. Maybe it's Oracle in general." hits too close to home, haha.
            – Grant Gordon
            yesterday











          • hmm is there a little weirdness exec'ing service because it's not what you want with the old sysvinits ? you don't want a sysvinit service for a dbus-activatable service, because running service can return failure if it races with someone else, right? I guess the ol' service API wants tightening up a bit first?
            – sourcejedi
            yesterday















          up vote
          1
          down vote



          accepted










          No. The process will be running in a different context as far as systemd is concerned.



          This is, in fact, one of the reasons that Desktop Bus service activation should be avoided. Service processes directly spawned by the Desktop Bus broker are part of its service, as far as systemd is concerned.



          One can move processes amongst control groups, with appropriate privileges. But this is only half of the job, and the other half, that of convincing systemd that it started a unit when it did not and rewriting the necessary parts of its internal data structures, is not provided for.



          This is not only not systemd's model, it is not the model of most service management subsystems.



          Far too many people's "just fine" service units for Oracle softwares actually are not, by the way, and are in House of Horror territory.



          Further reading



          • systemctl fails to accurately report status of daemons if they were started via mechanism other than systemctl

          • configure java daemon with systemd

          • https://unix.stackexchange.com/a/437461/5132

          • Jonathan de Boyne Pollard (2016). Avoid Desktop Bus (D-Bus) bus activation
            . nosh. Softwares.

          • Jonathan de Boyne Pollard (2015). The systemd House of Horror. Frequently Given Answers.





          share|improve this answer




















          • Your comments on D-Bus activation are on point, but only when activation happens at the dbus-daemon. As your separate article points out, when systemd is involved, things work fine. So D-Bus activation with systemd (which is done with service units having Type=dbus) should be perfectly fine, and doesn't suffer from the problems you describe. Given upstart is mostly gone at this point, I think it's important to point out or clarify the context of those problems with D-Bus activation. They were more relevant in the past, before Debian/Ubuntu switched to systemd by default.
            – Filipe Brandenburger
            yesterday










          • The problem continues to be as relevant now as it was. It is a misrepresentation (another mis-application of "fine" indeed) to say that systemd has somehow cured this. If the problem weren't relevant any more, the idiosyncratic and tightly coupled communications channel between the broker and systemd would no longer be needed. It of course still is needed, with the context that broker-spawned processes run in continuing unabated to be problematic, and the fact that it is idiosyncratic and too strongly coupled continues to be the part of the problem that the Upstart people identified it as.
            – JdeBP
            yesterday










          • Thank you! I appreciate all the documentation - I was worried that this might be the case, but it's good to be able to point to references. "Don't ask me why, so far, all of these have involved starting Java programs. Maybe it's Oracle in general." hits too close to home, haha.
            – Grant Gordon
            yesterday











          • hmm is there a little weirdness exec'ing service because it's not what you want with the old sysvinits ? you don't want a sysvinit service for a dbus-activatable service, because running service can return failure if it races with someone else, right? I guess the ol' service API wants tightening up a bit first?
            – sourcejedi
            yesterday













          up vote
          1
          down vote



          accepted







          up vote
          1
          down vote



          accepted






          No. The process will be running in a different context as far as systemd is concerned.



          This is, in fact, one of the reasons that Desktop Bus service activation should be avoided. Service processes directly spawned by the Desktop Bus broker are part of its service, as far as systemd is concerned.



          One can move processes amongst control groups, with appropriate privileges. But this is only half of the job, and the other half, that of convincing systemd that it started a unit when it did not and rewriting the necessary parts of its internal data structures, is not provided for.



          This is not only not systemd's model, it is not the model of most service management subsystems.



          Far too many people's "just fine" service units for Oracle softwares actually are not, by the way, and are in House of Horror territory.



          Further reading



          • systemctl fails to accurately report status of daemons if they were started via mechanism other than systemctl

          • configure java daemon with systemd

          • https://unix.stackexchange.com/a/437461/5132

          • Jonathan de Boyne Pollard (2016). Avoid Desktop Bus (D-Bus) bus activation
            . nosh. Softwares.

          • Jonathan de Boyne Pollard (2015). The systemd House of Horror. Frequently Given Answers.





          share|improve this answer












          No. The process will be running in a different context as far as systemd is concerned.



          This is, in fact, one of the reasons that Desktop Bus service activation should be avoided. Service processes directly spawned by the Desktop Bus broker are part of its service, as far as systemd is concerned.



          One can move processes amongst control groups, with appropriate privileges. But this is only half of the job, and the other half, that of convincing systemd that it started a unit when it did not and rewriting the necessary parts of its internal data structures, is not provided for.



          This is not only not systemd's model, it is not the model of most service management subsystems.



          Far too many people's "just fine" service units for Oracle softwares actually are not, by the way, and are in House of Horror territory.



          Further reading



          • systemctl fails to accurately report status of daemons if they were started via mechanism other than systemctl

          • configure java daemon with systemd

          • https://unix.stackexchange.com/a/437461/5132

          • Jonathan de Boyne Pollard (2016). Avoid Desktop Bus (D-Bus) bus activation
            . nosh. Softwares.

          • Jonathan de Boyne Pollard (2015). The systemd House of Horror. Frequently Given Answers.






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered yesterday









          JdeBP

          31.4k466145




          31.4k466145











          • Your comments on D-Bus activation are on point, but only when activation happens at the dbus-daemon. As your separate article points out, when systemd is involved, things work fine. So D-Bus activation with systemd (which is done with service units having Type=dbus) should be perfectly fine, and doesn't suffer from the problems you describe. Given upstart is mostly gone at this point, I think it's important to point out or clarify the context of those problems with D-Bus activation. They were more relevant in the past, before Debian/Ubuntu switched to systemd by default.
            – Filipe Brandenburger
            yesterday










          • The problem continues to be as relevant now as it was. It is a misrepresentation (another mis-application of "fine" indeed) to say that systemd has somehow cured this. If the problem weren't relevant any more, the idiosyncratic and tightly coupled communications channel between the broker and systemd would no longer be needed. It of course still is needed, with the context that broker-spawned processes run in continuing unabated to be problematic, and the fact that it is idiosyncratic and too strongly coupled continues to be the part of the problem that the Upstart people identified it as.
            – JdeBP
            yesterday










          • Thank you! I appreciate all the documentation - I was worried that this might be the case, but it's good to be able to point to references. "Don't ask me why, so far, all of these have involved starting Java programs. Maybe it's Oracle in general." hits too close to home, haha.
            – Grant Gordon
            yesterday











          • hmm is there a little weirdness exec'ing service because it's not what you want with the old sysvinits ? you don't want a sysvinit service for a dbus-activatable service, because running service can return failure if it races with someone else, right? I guess the ol' service API wants tightening up a bit first?
            – sourcejedi
            yesterday

















          • Your comments on D-Bus activation are on point, but only when activation happens at the dbus-daemon. As your separate article points out, when systemd is involved, things work fine. So D-Bus activation with systemd (which is done with service units having Type=dbus) should be perfectly fine, and doesn't suffer from the problems you describe. Given upstart is mostly gone at this point, I think it's important to point out or clarify the context of those problems with D-Bus activation. They were more relevant in the past, before Debian/Ubuntu switched to systemd by default.
            – Filipe Brandenburger
            yesterday










          • The problem continues to be as relevant now as it was. It is a misrepresentation (another mis-application of "fine" indeed) to say that systemd has somehow cured this. If the problem weren't relevant any more, the idiosyncratic and tightly coupled communications channel between the broker and systemd would no longer be needed. It of course still is needed, with the context that broker-spawned processes run in continuing unabated to be problematic, and the fact that it is idiosyncratic and too strongly coupled continues to be the part of the problem that the Upstart people identified it as.
            – JdeBP
            yesterday










          • Thank you! I appreciate all the documentation - I was worried that this might be the case, but it's good to be able to point to references. "Don't ask me why, so far, all of these have involved starting Java programs. Maybe it's Oracle in general." hits too close to home, haha.
            – Grant Gordon
            yesterday











          • hmm is there a little weirdness exec'ing service because it's not what you want with the old sysvinits ? you don't want a sysvinit service for a dbus-activatable service, because running service can return failure if it races with someone else, right? I guess the ol' service API wants tightening up a bit first?
            – sourcejedi
            yesterday
















          Your comments on D-Bus activation are on point, but only when activation happens at the dbus-daemon. As your separate article points out, when systemd is involved, things work fine. So D-Bus activation with systemd (which is done with service units having Type=dbus) should be perfectly fine, and doesn't suffer from the problems you describe. Given upstart is mostly gone at this point, I think it's important to point out or clarify the context of those problems with D-Bus activation. They were more relevant in the past, before Debian/Ubuntu switched to systemd by default.
          – Filipe Brandenburger
          yesterday




          Your comments on D-Bus activation are on point, but only when activation happens at the dbus-daemon. As your separate article points out, when systemd is involved, things work fine. So D-Bus activation with systemd (which is done with service units having Type=dbus) should be perfectly fine, and doesn't suffer from the problems you describe. Given upstart is mostly gone at this point, I think it's important to point out or clarify the context of those problems with D-Bus activation. They were more relevant in the past, before Debian/Ubuntu switched to systemd by default.
          – Filipe Brandenburger
          yesterday












          The problem continues to be as relevant now as it was. It is a misrepresentation (another mis-application of "fine" indeed) to say that systemd has somehow cured this. If the problem weren't relevant any more, the idiosyncratic and tightly coupled communications channel between the broker and systemd would no longer be needed. It of course still is needed, with the context that broker-spawned processes run in continuing unabated to be problematic, and the fact that it is idiosyncratic and too strongly coupled continues to be the part of the problem that the Upstart people identified it as.
          – JdeBP
          yesterday




          The problem continues to be as relevant now as it was. It is a misrepresentation (another mis-application of "fine" indeed) to say that systemd has somehow cured this. If the problem weren't relevant any more, the idiosyncratic and tightly coupled communications channel between the broker and systemd would no longer be needed. It of course still is needed, with the context that broker-spawned processes run in continuing unabated to be problematic, and the fact that it is idiosyncratic and too strongly coupled continues to be the part of the problem that the Upstart people identified it as.
          – JdeBP
          yesterday












          Thank you! I appreciate all the documentation - I was worried that this might be the case, but it's good to be able to point to references. "Don't ask me why, so far, all of these have involved starting Java programs. Maybe it's Oracle in general." hits too close to home, haha.
          – Grant Gordon
          yesterday





          Thank you! I appreciate all the documentation - I was worried that this might be the case, but it's good to be able to point to references. "Don't ask me why, so far, all of these have involved starting Java programs. Maybe it's Oracle in general." hits too close to home, haha.
          – Grant Gordon
          yesterday













          hmm is there a little weirdness exec'ing service because it's not what you want with the old sysvinits ? you don't want a sysvinit service for a dbus-activatable service, because running service can return failure if it races with someone else, right? I guess the ol' service API wants tightening up a bit first?
          – sourcejedi
          yesterday





          hmm is there a little weirdness exec'ing service because it's not what you want with the old sysvinits ? you don't want a sysvinit service for a dbus-activatable service, because running service can return failure if it races with someone else, right? I guess the ol' service API wants tightening up a bit first?
          – sourcejedi
          yesterday













          up vote
          0
          down vote













          In short, there isn't a way to have systemd consider a service to be started unless it was started by systemd itself. One of the main points of systemd is consistency in managing services and having separate ways to start a service goes against that idea.



          Now, systemd does have a provision to manage processes that are started externally, which seems to be somewhat suitable for the case you describe. That's actually a separate kind of unit, a scope unit.



          Using a scope unit still requires your external system to interact with systemd, since a scope unit can only be started with a D-Bus request to systemd, in which a PID is passed which is used as the initial process in the scope. Also, when a scope unit is started, systemd still wants to create the cgroups itself (it will then move the passed PID into the created cgroups.) So, this needs support from the application creating new processes, if it wants systemd to manage those as a scope.



          In short, avoid having two separate ways to start a service. If you need to use the third party service manager, use only that.



          If the issue you are trying to solve is to start the service during boot up, then:



          1. Check if your third party manager (in your case, Oracle NodeManager) supports configuring services during boot up. As it's managing the service, it should manage service during boot up as well.


          2. If you get systemd involved, then use a simple oneshot service unit that simply requests the third party manager to start the service. This means contacting the third party manager (in your case, Oracle NodeManager) through an API or RPC of some kind, maybe through HTTP, and telling it to start the service.


          If you use the systemd oneshot for startup, then name your unit appropriately (like "start-foo" or "initial-foo" or "foo-startup") to make it clear it won't stay "up", and keep RemainAfterExit= as no (the default) so checking the status on that unit will just say it's finished successfully, so there's no confusion about it reflecting the status of the service running under the third party manager.






          share|improve this answer






















          • I foresee people reading this and running startNodeManager.sh as a oneshot service. They even have the likes of stackoverflow.com/questions/30640717 for bodges to pile on when it does not work. More House of Horror stuff. (-:
            – JdeBP
            yesterday










          • @JdeBP Rephrased that last part to make that more clear, please take a look.
            – Filipe Brandenburger
            15 hours ago














          up vote
          0
          down vote













          In short, there isn't a way to have systemd consider a service to be started unless it was started by systemd itself. One of the main points of systemd is consistency in managing services and having separate ways to start a service goes against that idea.



          Now, systemd does have a provision to manage processes that are started externally, which seems to be somewhat suitable for the case you describe. That's actually a separate kind of unit, a scope unit.



          Using a scope unit still requires your external system to interact with systemd, since a scope unit can only be started with a D-Bus request to systemd, in which a PID is passed which is used as the initial process in the scope. Also, when a scope unit is started, systemd still wants to create the cgroups itself (it will then move the passed PID into the created cgroups.) So, this needs support from the application creating new processes, if it wants systemd to manage those as a scope.



          In short, avoid having two separate ways to start a service. If you need to use the third party service manager, use only that.



          If the issue you are trying to solve is to start the service during boot up, then:



          1. Check if your third party manager (in your case, Oracle NodeManager) supports configuring services during boot up. As it's managing the service, it should manage service during boot up as well.


          2. If you get systemd involved, then use a simple oneshot service unit that simply requests the third party manager to start the service. This means contacting the third party manager (in your case, Oracle NodeManager) through an API or RPC of some kind, maybe through HTTP, and telling it to start the service.


          If you use the systemd oneshot for startup, then name your unit appropriately (like "start-foo" or "initial-foo" or "foo-startup") to make it clear it won't stay "up", and keep RemainAfterExit= as no (the default) so checking the status on that unit will just say it's finished successfully, so there's no confusion about it reflecting the status of the service running under the third party manager.






          share|improve this answer






















          • I foresee people reading this and running startNodeManager.sh as a oneshot service. They even have the likes of stackoverflow.com/questions/30640717 for bodges to pile on when it does not work. More House of Horror stuff. (-:
            – JdeBP
            yesterday










          • @JdeBP Rephrased that last part to make that more clear, please take a look.
            – Filipe Brandenburger
            15 hours ago












          up vote
          0
          down vote










          up vote
          0
          down vote









          In short, there isn't a way to have systemd consider a service to be started unless it was started by systemd itself. One of the main points of systemd is consistency in managing services and having separate ways to start a service goes against that idea.



          Now, systemd does have a provision to manage processes that are started externally, which seems to be somewhat suitable for the case you describe. That's actually a separate kind of unit, a scope unit.



          Using a scope unit still requires your external system to interact with systemd, since a scope unit can only be started with a D-Bus request to systemd, in which a PID is passed which is used as the initial process in the scope. Also, when a scope unit is started, systemd still wants to create the cgroups itself (it will then move the passed PID into the created cgroups.) So, this needs support from the application creating new processes, if it wants systemd to manage those as a scope.



          In short, avoid having two separate ways to start a service. If you need to use the third party service manager, use only that.



          If the issue you are trying to solve is to start the service during boot up, then:



          1. Check if your third party manager (in your case, Oracle NodeManager) supports configuring services during boot up. As it's managing the service, it should manage service during boot up as well.


          2. If you get systemd involved, then use a simple oneshot service unit that simply requests the third party manager to start the service. This means contacting the third party manager (in your case, Oracle NodeManager) through an API or RPC of some kind, maybe through HTTP, and telling it to start the service.


          If you use the systemd oneshot for startup, then name your unit appropriately (like "start-foo" or "initial-foo" or "foo-startup") to make it clear it won't stay "up", and keep RemainAfterExit= as no (the default) so checking the status on that unit will just say it's finished successfully, so there's no confusion about it reflecting the status of the service running under the third party manager.






          share|improve this answer














          In short, there isn't a way to have systemd consider a service to be started unless it was started by systemd itself. One of the main points of systemd is consistency in managing services and having separate ways to start a service goes against that idea.



          Now, systemd does have a provision to manage processes that are started externally, which seems to be somewhat suitable for the case you describe. That's actually a separate kind of unit, a scope unit.



          Using a scope unit still requires your external system to interact with systemd, since a scope unit can only be started with a D-Bus request to systemd, in which a PID is passed which is used as the initial process in the scope. Also, when a scope unit is started, systemd still wants to create the cgroups itself (it will then move the passed PID into the created cgroups.) So, this needs support from the application creating new processes, if it wants systemd to manage those as a scope.



          In short, avoid having two separate ways to start a service. If you need to use the third party service manager, use only that.



          If the issue you are trying to solve is to start the service during boot up, then:



          1. Check if your third party manager (in your case, Oracle NodeManager) supports configuring services during boot up. As it's managing the service, it should manage service during boot up as well.


          2. If you get systemd involved, then use a simple oneshot service unit that simply requests the third party manager to start the service. This means contacting the third party manager (in your case, Oracle NodeManager) through an API or RPC of some kind, maybe through HTTP, and telling it to start the service.


          If you use the systemd oneshot for startup, then name your unit appropriately (like "start-foo" or "initial-foo" or "foo-startup") to make it clear it won't stay "up", and keep RemainAfterExit= as no (the default) so checking the status on that unit will just say it's finished successfully, so there's no confusion about it reflecting the status of the service running under the third party manager.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 15 hours ago

























          answered yesterday









          Filipe Brandenburger

          5,7241624




          5,7241624











          • I foresee people reading this and running startNodeManager.sh as a oneshot service. They even have the likes of stackoverflow.com/questions/30640717 for bodges to pile on when it does not work. More House of Horror stuff. (-:
            – JdeBP
            yesterday










          • @JdeBP Rephrased that last part to make that more clear, please take a look.
            – Filipe Brandenburger
            15 hours ago
















          • I foresee people reading this and running startNodeManager.sh as a oneshot service. They even have the likes of stackoverflow.com/questions/30640717 for bodges to pile on when it does not work. More House of Horror stuff. (-:
            – JdeBP
            yesterday










          • @JdeBP Rephrased that last part to make that more clear, please take a look.
            – Filipe Brandenburger
            15 hours ago















          I foresee people reading this and running startNodeManager.sh as a oneshot service. They even have the likes of stackoverflow.com/questions/30640717 for bodges to pile on when it does not work. More House of Horror stuff. (-:
          – JdeBP
          yesterday




          I foresee people reading this and running startNodeManager.sh as a oneshot service. They even have the likes of stackoverflow.com/questions/30640717 for bodges to pile on when it does not work. More House of Horror stuff. (-:
          – JdeBP
          yesterday












          @JdeBP Rephrased that last part to make that more clear, please take a look.
          – Filipe Brandenburger
          15 hours ago




          @JdeBP Rephrased that last part to make that more clear, please take a look.
          – Filipe Brandenburger
          15 hours ago

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f481535%2fcan-systemd-adopt-or-inherit-a-process-or-cgroup%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Displaying single band from multi-band raster using QGIS

          How many registers does an x86_64 CPU actually have?