[systemd-devel] Auto-start of a Service in systemd

Raghavendra. H. R raghuhr84 at gmail.com
Wed Oct 5 12:30:41 UTC 2016


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 Borzenkov <arvidjaar at gmail.com>
wrote:

> On Wed, Oct 5, 2016 at 1:19 PM, Raghavendra. H. R <raghuhr84 at gmail.com>
> 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 <raghuhr84 at gmail.com>
> > 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 <arvidjaar at gmail.com>
> >> wrote:
> >>>
> >>> On Wed, Oct 5, 2016 at 12:23 PM, Raghavendra. H. R <
> raghuhr84 at 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?
> >>
> >>
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20161005/e381dd42/attachment.html>


More information about the systemd-devel mailing list