Re: [systemd-devel] Auto-start of a Service in systemd
Am Wed, 5 Oct 2016 18:00:41 +0530 schrieb "Raghavendra. H. R": > Andrei, > > Your doubt is absolutely correct. Default target of the system as > nothing to do with auto start of services. > > I checked both graphical.target & multi-user.target, surprisingly I > don't see any big difference in these. Both of the files are almost > same except multi-user.target have dependency *After=* with > *rescue.service & rescue.target* which is restricting > multi-user.target from starting. > > However graphical.target don't depend on rescue services, so it is > active & started. And by making graphical.target as dependency in my > unit file solved my problem. > > Hopefully if I remove the rescue services dependency from > multi-user.target and add it as dependency then my service should > come up without failures. "After=" does not have such an impact. It won't block a service from starting if the services in "After=" aren't started. It's just an ordering dependency. If the dependents aren't enabled they are just ignored. Instead, "Requires=" and "Wants=" give stronger dependencies. You can check the status of multi-user.target: $ systemctl status multi-user.target ● multi-user.target - Multi-User System Loaded: loaded (/usr/lib/systemd/system/multi-user.target; static; vendor preset: disabled) Active: active since Mo 2016-10-03 16:44:14 CEST; 3 days ago Docs: man:systemd.special(7) Okt 03 16:44:14 jupiter.sol.local systemd[1]: Reached target Multi-User System. $ systemctl get-default graphical.target As you see, multi-user.target has been pulled in for me. You can check the order of targets started with: $ systemd-analyze critical-chain The time after the unit is active or started is printed after the "@" character. The time the unit takes to start is printed after the "+" character. graphical.target @5.383s └─multi-user.target @5.383s └─machines.target @5.383s └─systemd-nspawn@gentoo\x2delasticsearch\x2dbase.service @2.219s +3.164s └─network.target @2.204s └─systemd-networkd.service @2.031s +172ms └─dbus.service @2.005s └─basic.target @1.920s └─sockets.target @1.920s └─docker.socket @1.896s +24ms └─sysinit.target @1.889s └─systemd-timesyncd.service @1.649s +239ms └─systemd-tmpfiles-setup.service @1.576s +66ms └─local-fs.target @1.575s └─run-user-500.mount @5.403s └─local-fs-pre.target @565ms └─systemd-tmpfiles-setup-dev.service @383ms +179ms └─kmod-static-nodes.service @148ms +42ms └─system.slice └─-.slice Also, take note that "After=" doesn't wait for a service to finish its startup. Maybe, your service is just triggered way to early? You may want to add "After=network.target" or similar synchronization points of the graph above. Make sure that after editing "WantedBy=" you may need to "systemctl reenable" your service. If you didn't use "systemctl edit --full" you may also need to use "systemctl daemon-reload" before re-enabling the service. Otherwise you may see strange effects similar to what you described. > Thanks for your valuable feedback. > > Regards, > Raghavendra H R > > > > -- > Regards, > > Raghavendra. H. R > (Raghu) > > On Wed, Oct 5, 2016 at 4:55 PM, Andrei Borzenkov > wrote: > > > On Wed, Oct 5, 2016 at 1:19 PM, Raghavendra. H. R > > wrote: > > > It's working fine now. We should give the default target of the > > > system > > for > > > WantedBy= of the Install section. > > > So I used graphical.target in the Install section and it fixed my > > > issue. > > > > I doubt it was the reason. grpahical.target pulls in > > multi-user.target unless you have very customized unit definitions. -- Regards, Kai Replies to list-only preferred. ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] Auto-start of a Service in systemd
Andrei, Your doubt is absolutely correct. Default target of the system as nothing to do with auto start of services. I checked both graphical.target & multi-user.target, surprisingly I don't see any big difference in these. Both of the files are almost same except multi-user.target have dependency *After=* with *rescue.service & rescue.target* which is restricting multi-user.target from starting. However graphical.target don't depend on rescue services, so it is active & started. And by making graphical.target as dependency in my unit file solved my problem. Hopefully if I remove the rescue services dependency from multi-user.target and add it as dependency then my service should come up without failures. Thanks for your valuable feedback. Regards, Raghavendra H R -- Regards, Raghavendra. H. R (Raghu) On Wed, Oct 5, 2016 at 4:55 PM, Andrei Borzenkovwrote: > On Wed, Oct 5, 2016 at 1:19 PM, Raghavendra. H. R > wrote: > > It's working fine now. We should give the default target of the system > for > > WantedBy= of the Install section. > > So I used graphical.target in the Install section and it fixed my issue. > > > > I doubt it was the reason. grpahical.target pulls in multi-user.target > unless you have very customized unit definitions. > > > Thanks for the information. > > > > > > > > -- > > Regards, > > > > Raghavendra. H. R > > (Raghu) > > > > On Wed, Oct 5, 2016 at 3:12 PM, Raghavendra. H. R > > wrote: > >> > >> I ran "systemctl enable test.service" but when I restart it shows only > >> that the service is only enabled but not active and running. > >> > >> Here is the status of test.service > >> > >> ? test.service - Hey Bings > >>Loaded: loaded (/lib/systemd/system/test.service; enabled) > >>Active: inactive (dead) > >> > >> > >> For WantedBy= which attribute should be given, whether it is > >> "default.target" or the default target of the system ? > >> Running systemctl get-default shows graphical.target as the default > >> target. > >> > >> -- > >> Regards, > >> > >> Raghavendra. H. R > >> (Raghu) > >> > >> On Wed, Oct 5, 2016 at 2:59 PM, Andrei Borzenkov > >> wrote: > >>> > >>> On Wed, Oct 5, 2016 at 12:23 PM, Raghavendra. H. R < > raghuh...@gmail.com> > >>> wrote: > >>> > Hi All, > >>> > > >>> > I'm a newbie in Systemd init system and I'm trying to auto boot/start > >>> > my > >>> > service in systemd. But my service gets only enabled and it never > runs > >>> > automatically. > >>> > > >>> > I modifying my unit file to depend on sysinit.target and > >>> > multi-user.target > >>> > by making use of I used After= this also didnt help. > >>> > > >>> > I would like to do something in my unit file from which systemd > starts > >>> > my > >>> > service automatically after starting it's own system related > services. > >>> > > >>> > >>> There is no such thing as "own systemd services". All services are > >>> equal (but some are more equal than others :) > >>> > >>> > Can anyone help me regarding this ? > >>> > > >>> > > >>> > My sample service > >>> > = > >>> > [Unit] > >>> > Description=Hey Bings > >>> > > >>> > [Service] > >>> > ExecStart="Run an executable" > >>> > > >>> > [Install] > >>> > WantedBy=multi-user.target or sysinit.target > >>> > > >>> > >>> sysinit.target is wrong, it should never be used for normal service. > >>> multi-user.target should work as long as it is your default target (or > >>> dependency of default target). > >>> > >>> You did run "systemctl enable your.service", did not you? What > >>> "systemctl status your.service" says? > >> > >> > > > ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] Auto-start of a Service in systemd
On Wed, 05.10.16 14:53, Raghavendra. H. R (raghuh...@gmail.com) wrote: > Hi All, > > I'm a newbie in Systemd init system and I'm trying to auto boot/start my > service in systemd. But my service gets only enabled and it never runs > automatically. > > I modifying my unit file to depend on sysinit.target and multi-user.target > by making use of I used *After=* this also didnt help. > > *I would like to do something in my unit file from which systemd starts my > service automatically after starting it's own system related services. * > > Can anyone help me regarding this ? > > > My sample service > = > [Unit] > Description=Hey Bings > > [Service] > ExecStart="Run an executable" > > [Install] > WantedBy=multi-user.target *or* sysinit.target You want to use multi-user.target here. "sysinit.target" is only for special early-boot services. After dropping in this file use "systemctl enable ..." to hook the unit into the boot process for subsequent boots. To also start it immediately, use "systemctl start ...". You may also do both operations in one go by using "systemctl enable --now ...". Lennart -- Lennart Poettering, Red Hat ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] Auto-start of a Service in systemd
On Wed, Oct 5, 2016 at 1:19 PM, Raghavendra. H. Rwrote: > It's working fine now. We should give the default target of the system for > WantedBy= of the Install section. > So I used graphical.target in the Install section and it fixed my issue. > I doubt it was the reason. grpahical.target pulls in multi-user.target unless you have very customized unit definitions. > Thanks for the information. > > > > -- > Regards, > > Raghavendra. H. R > (Raghu) > > On Wed, Oct 5, 2016 at 3:12 PM, Raghavendra. H. R > wrote: >> >> I ran "systemctl enable test.service" but when I restart it shows only >> that the service is only enabled but not active and running. >> >> Here is the status of test.service >> >> ? test.service - Hey Bings >>Loaded: loaded (/lib/systemd/system/test.service; enabled) >>Active: inactive (dead) >> >> >> For WantedBy= which attribute should be given, whether it is >> "default.target" or the default target of the system ? >> Running systemctl get-default shows graphical.target as the default >> target. >> >> -- >> Regards, >> >> Raghavendra. H. R >> (Raghu) >> >> On Wed, Oct 5, 2016 at 2:59 PM, Andrei Borzenkov >> wrote: >>> >>> On Wed, Oct 5, 2016 at 12:23 PM, Raghavendra. H. R >>> wrote: >>> > Hi All, >>> > >>> > I'm a newbie in Systemd init system and I'm trying to auto boot/start >>> > my >>> > service in systemd. But my service gets only enabled and it never runs >>> > automatically. >>> > >>> > I modifying my unit file to depend on sysinit.target and >>> > multi-user.target >>> > by making use of I used After= this also didnt help. >>> > >>> > I would like to do something in my unit file from which systemd starts >>> > my >>> > service automatically after starting it's own system related services. >>> > >>> >>> There is no such thing as "own systemd services". All services are >>> equal (but some are more equal than others :) >>> >>> > Can anyone help me regarding this ? >>> > >>> > >>> > My sample service >>> > = >>> > [Unit] >>> > Description=Hey Bings >>> > >>> > [Service] >>> > ExecStart="Run an executable" >>> > >>> > [Install] >>> > WantedBy=multi-user.target or sysinit.target >>> > >>> >>> sysinit.target is wrong, it should never be used for normal service. >>> multi-user.target should work as long as it is your default target (or >>> dependency of default target). >>> >>> You did run "systemctl enable your.service", did not you? What >>> "systemctl status your.service" says? >> >> > ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] Auto-start of a Service in systemd
It's working fine now. We should give the default target of the system for *WantedBy= *of the Install section. So I used graphical.target in the Install section and it fixed my issue. Thanks for the information. -- Regards, Raghavendra. H. R (Raghu) On Wed, Oct 5, 2016 at 3:12 PM, Raghavendra. H. Rwrote: > I ran *"systemctl enable test.service" *but when I restart it shows only > that the service is only enabled but not active and running. > > Here is the status of test.service > > *? test.service - Hey Bings* > * Loaded: loaded (/lib/systemd/system/test.service; enabled)* > * Active: inactive (dead)* > > > For *WantedBy= *which attribute should be given, whether it is > "default.target" or the default target of the system ? > Running *systemctl get-default* shows graphical.target as the default > target. > > -- > Regards, > > Raghavendra. H. R > (Raghu) > > On Wed, Oct 5, 2016 at 2:59 PM, Andrei Borzenkov > wrote: > >> On Wed, Oct 5, 2016 at 12:23 PM, Raghavendra. H. R >> wrote: >> > Hi All, >> > >> > I'm a newbie in Systemd init system and I'm trying to auto boot/start my >> > service in systemd. But my service gets only enabled and it never runs >> > automatically. >> > >> > I modifying my unit file to depend on sysinit.target and >> multi-user.target >> > by making use of I used After= this also didnt help. >> > >> > I would like to do something in my unit file from which systemd starts >> my >> > service automatically after starting it's own system related services. >> > >> >> There is no such thing as "own systemd services". All services are >> equal (but some are more equal than others :) >> >> > Can anyone help me regarding this ? >> > >> > >> > My sample service >> > = >> > [Unit] >> > Description=Hey Bings >> > >> > [Service] >> > ExecStart="Run an executable" >> > >> > [Install] >> > WantedBy=multi-user.target or sysinit.target >> > >> >> sysinit.target is wrong, it should never be used for normal service. >> multi-user.target should work as long as it is your default target (or >> dependency of default target). >> >> You did run "systemctl enable your.service", did not you? What >> "systemctl status your.service" says? >> > > ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] Auto-start of a Service in systemd
I ran *"systemctl enable test.service" *but when I restart it shows only that the service is only enabled but not active and running. Here is the status of test.service *? test.service - Hey Bings* * Loaded: loaded (/lib/systemd/system/test.service; enabled)* * Active: inactive (dead)* For *WantedBy= *which attribute should be given, whether it is "default.target" or the default target of the system ? Running *systemctl get-default* shows graphical.target as the default target. -- Regards, Raghavendra. H. R (Raghu) On Wed, Oct 5, 2016 at 2:59 PM, Andrei Borzenkovwrote: > On Wed, Oct 5, 2016 at 12:23 PM, Raghavendra. H. R > wrote: > > Hi All, > > > > I'm a newbie in Systemd init system and I'm trying to auto boot/start my > > service in systemd. But my service gets only enabled and it never runs > > automatically. > > > > I modifying my unit file to depend on sysinit.target and > multi-user.target > > by making use of I used After= this also didnt help. > > > > I would like to do something in my unit file from which systemd starts my > > service automatically after starting it's own system related services. > > > > There is no such thing as "own systemd services". All services are > equal (but some are more equal than others :) > > > Can anyone help me regarding this ? > > > > > > My sample service > > = > > [Unit] > > Description=Hey Bings > > > > [Service] > > ExecStart="Run an executable" > > > > [Install] > > WantedBy=multi-user.target or sysinit.target > > > > sysinit.target is wrong, it should never be used for normal service. > multi-user.target should work as long as it is your default target (or > dependency of default target). > > You did run "systemctl enable your.service", did not you? What > "systemctl status your.service" says? > ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] Auto-start of a Service in systemd
On Wed, Oct 5, 2016 at 12:23 PM, Raghavendra. H. Rwrote: > Hi All, > > I'm a newbie in Systemd init system and I'm trying to auto boot/start my > service in systemd. But my service gets only enabled and it never runs > automatically. > > I modifying my unit file to depend on sysinit.target and multi-user.target > by making use of I used After= this also didnt help. > > I would like to do something in my unit file from which systemd starts my > service automatically after starting it's own system related services. > There is no such thing as "own systemd services". All services are equal (but some are more equal than others :) > Can anyone help me regarding this ? > > > My sample service > = > [Unit] > Description=Hey Bings > > [Service] > ExecStart="Run an executable" > > [Install] > WantedBy=multi-user.target or sysinit.target > sysinit.target is wrong, it should never be used for normal service. multi-user.target should work as long as it is your default target (or dependency of default target). You did run "systemctl enable your.service", did not you? What "systemctl status your.service" says? ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel