Re: [systemd-devel] Systemd killed processes of custom services instead of graceful shutdown

2020-06-19 Thread Andrei Borzenkov
18.06.2020 10:07, Kamal Rathi пишет:
> 
> Now I am more eager to know if is it possible to run anything before it
> kills users processes  at shutdown / reboot / halt.

User processes run either as part of user session or as part of user
service. The former is session-xxx.scope, the latter is
user@UID.service. You could add Before=your.service to user@.service
template to make sure your.service is stopped first. Current version of
systemd allows creation of drop-ins in session-.scope.d as well to add
dependency to all session scopes. Check systemd.unit man page.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Systemd killed processes of custom services instead of graceful shutdown

2020-06-18 Thread Kamal Rathi
>- ExecStop command returns before application is actually stopped.
>ExecStop must be synchronous, systemd assumes service is stopped when
>ExecStop command completes
   Correct, and yes i finally figure out what service i have to make
grid and rdbms dependent so that applicaiton shutdown will be graceful

>- stopping takes longer then TimeoutStopSec
   yes i have put a Timeout and it is working correct

>- your actual database it still started outside of rdbms.service. The
>only process shown in your output is listener, but I would expect rather
>more of Oracle there

 database was started by grid.service because when it sees that it was
kill by my processes then it will start those services,
 but that part is solved

Now I am more eager to know if is it possible to run anything before it
kills users processes  at shutdown / reboot / halt.
or maybe i can be wrong but when shutdown / reboot initiates , it seems it
sends a kill signal to all processes parallely.
I tried to capture ps -efj when shutdown initiates and I have seen few bash
sessions get into defunct state(systemd-user-sessions stop [maybe this has
been called]).
After reading man pages of systemd, as shutdown is being initiated control
is being passed from PID 1 to /usr/lib/systemd/systemd-shutdown.
Can I create any dependency in my custom service so that before sending
kill signals to processes or stopping users sessions scope at shutdown /
reboot / halt / poweroff?

Thanks a lot for such advice and I have clear my doubts towards systemd
with all discussions.

On Wed, Jun 17, 2020 at 12:23 AM Andrei Borzenkov 
wrote:

> 17.06.2020 07:46, Kamal Rathi пишет:
> >> Please take at least some efforts to format mail so that it can be
> >> properly understood. Otherwise I am afraid your mails will simply be
> >> ignored.
> >
> >I am sorry for inconvenience, i will try to follow correct
> approach
> > afterwards while replying
> >
> >> How RemainAfterExit affects *startup* of services?
> >
> >   The services worked as expected and as i fixed the issue where it
> was
> > using su in script.
> >   As in background there was SysVinit script which was getting
> invoked
> > when system boot and makes processes falls in users.slice
> >   So the startup is working perfectly after disabling that SysVinit
> > script.
> >
> >> So I was right. Your programs are running as user services or part of
> >> user sessions.
> >
> >  You were absolutely right, I tried to dig into that and find out as
> it
> > was using internally su,
> >  but now only problem remains is shutdown order.
> >  As I have created a dependency that rdbms.service should start after
> > grid.service which works perfect at boot.
> > But when I do shutdown / reboot both services stop simultaneously.
> > which i want my grid.service to wait first before rdbms.service will
> > stop
> > As Type mentioned in services are oneshot.
> >
> >> dmesg output does not contain any systemd log. Anyway, we already know
> >> that your services are not really system services.
> >
> > So my service is system services, as let me attach cgls output
> >
> > └─system.slice
> >  ├─rdbms.service
> >  │ └─8039 /sarahn9db/db/11.2.0/bin/tnslsnr sarahn9 -inherit
> >  ├─grid.service
> >  │ ├─  5316 /grid/gi/11.2.0/bin/ohasd.bin reboot
> >  │ ├─  6159 /grid/gi/11.2.0/bin/cssdagent
> >
>
> The obvious possibilities
>
> - ExecStop command returns before application is actually stopped.
> ExecStop must be synchronous, systemd assumes service is stopped when
> ExecStop command completes
>
> - stopping takes longer then TimeoutStopSec
>
> - your actual database it still started outside of rdbms.service. The
> only process shown in your output is listener, but I would expect rather
> more of Oracle there
>
> Without logs it is impossible to say anything more specific.
>
>
> > On Tue, Jun 16, 2020 at 12:23 AM Andrei Borzenkov 
> > wrote:
> >
> >> 16.06.2020 07:36, Kamal Rathi пишет:
> >>> The fact that you need RemainAfterExit at all hints that processes that
> >>> belong to your service are not running as part of service control
> group.
> >>> Knowing how Oracle has traditionally been managed, I suspect that you
> >>> perform "su - oracle_owner" or similar to start them in which case all
> >>> actual service processes become part of respective user sessions, and
> >>> not part of your system services. There is no way to synchronize
> >>> stopping of processes/services belonging to different users. They are
> >>> completely independent and shutdown for all sessions is initiated in
> >>> parallel.
> >>>
> >>
> >> Please take at least some efforts to format mail so that it can be
> >> properly understood. Otherwise I am afraid your mails will simply be
> >> ignored.
> >>
> >>> If my theory is correct, the fix would be to actually run your systemd
> >>> services as systemd services. If my theory is wrong, provide full from
> >>> system boot to shutdown where it could be 

Re: [systemd-devel] Systemd killed processes of custom services instead of graceful shutdown

2020-06-16 Thread Andrei Borzenkov
17.06.2020 07:46, Kamal Rathi пишет:
>> Please take at least some efforts to format mail so that it can be
>> properly understood. Otherwise I am afraid your mails will simply be
>> ignored.
> 
>I am sorry for inconvenience, i will try to follow correct approach
> afterwards while replying
> 
>> How RemainAfterExit affects *startup* of services?
> 
>   The services worked as expected and as i fixed the issue where it was
> using su in script.
>   As in background there was SysVinit script which was getting invoked
> when system boot and makes processes falls in users.slice
>   So the startup is working perfectly after disabling that SysVinit
> script.
> 
>> So I was right. Your programs are running as user services or part of
>> user sessions.
> 
>  You were absolutely right, I tried to dig into that and find out as it
> was using internally su,
>  but now only problem remains is shutdown order.
>  As I have created a dependency that rdbms.service should start after
> grid.service which works perfect at boot.
> But when I do shutdown / reboot both services stop simultaneously.
> which i want my grid.service to wait first before rdbms.service will
> stop
> As Type mentioned in services are oneshot.
> 
>> dmesg output does not contain any systemd log. Anyway, we already know
>> that your services are not really system services.
> 
> So my service is system services, as let me attach cgls output
> 
> └─system.slice
>  ├─rdbms.service
>  │ └─8039 /sarahn9db/db/11.2.0/bin/tnslsnr sarahn9 -inherit
>  ├─grid.service
>  │ ├─  5316 /grid/gi/11.2.0/bin/ohasd.bin reboot
>  │ ├─  6159 /grid/gi/11.2.0/bin/cssdagent
> 

The obvious possibilities

- ExecStop command returns before application is actually stopped.
ExecStop must be synchronous, systemd assumes service is stopped when
ExecStop command completes

- stopping takes longer then TimeoutStopSec

- your actual database it still started outside of rdbms.service. The
only process shown in your output is listener, but I would expect rather
more of Oracle there

Without logs it is impossible to say anything more specific.


> On Tue, Jun 16, 2020 at 12:23 AM Andrei Borzenkov 
> wrote:
> 
>> 16.06.2020 07:36, Kamal Rathi пишет:
>>> The fact that you need RemainAfterExit at all hints that processes that
>>> belong to your service are not running as part of service control group.
>>> Knowing how Oracle has traditionally been managed, I suspect that you
>>> perform "su - oracle_owner" or similar to start them in which case all
>>> actual service processes become part of respective user sessions, and
>>> not part of your system services. There is no way to synchronize
>>> stopping of processes/services belonging to different users. They are
>>> completely independent and shutdown for all sessions is initiated in
>>> parallel.
>>>
>>
>> Please take at least some efforts to format mail so that it can be
>> properly understood. Otherwise I am afraid your mails will simply be
>> ignored.
>>
>>> If my theory is correct, the fix would be to actually run your systemd
>>> services as systemd services. If my theory is wrong, provide full from
>>> system boot to shutdown where it could be seen how your services are
>>> started/stopped. Enabling systemd debug log level when doing it
>>> certainly won't harm.
>>>
>>>
>>>
>>> I have incorporated Type=oneshot and remainAfterExit=yes as it was
>> helpful
>>> in startup of services,
>>
>>
>> How RemainAfterExit affects *startup* of services?
>>
>>> but still grid.service are starting up in
>>> user.slice
>>
>> So I was right. Your programs are running as user services or part of
>> user sessions.
>>
>>> and shutdown was giving the same results
>>> I am attaching debug logs .
>>>
>>
>> dmesg output does not contain any systemd log. Anyway, we already know
>> that your services are not really system services.
>>
>>> On Mon, Jun 15, 2020 at 10:34 AM Andrei Borzenkov 
>>> wrote:
>>>
 15.06.2020 11:01, Kamal Rathi пишет:
> Hi Team,
>
> I have two services which are dependent on each other and are working
 fine
> at boot up but at shutdown / reboot , the processes get killed as
 shutdown
> got initated.
>
> Services are running fine in particular order but processes got killed
>> .I
> have enabled lingering on both users and changed confgiuration in
> logind.conf to KillUserProcesses=no but still issue is same
>

 Lingering/KillUserProcesses are relevant only for user services/sessions
 and so far there was no indication you use either.

> ##
> Systemd service files content are below
>
> cat /etc/systemd/system/grid.service
> [Unit]
> Description=Service to auto start Oracle ASM application
> Before=rdbms.service
> After=syslog.target network.target nfs-mountd.service autofs.service
> systemd-user-sessions.service system.slice
> [Service]
> Type=simple
> TimeoutSec=5min

Re: [systemd-devel] Systemd killed processes of custom services instead of graceful shutdown

2020-06-16 Thread Kamal Rathi
>Please take at least some efforts to format mail so that it can be
>properly understood. Otherwise I am afraid your mails will simply be
>ignored.

   I am sorry for inconvenience, i will try to follow correct approach
afterwards while replying

> How RemainAfterExit affects *startup* of services?

  The services worked as expected and as i fixed the issue where it was
using su in script.
  As in background there was SysVinit script which was getting invoked
when system boot and makes processes falls in users.slice
  So the startup is working perfectly after disabling that SysVinit
script.

>So I was right. Your programs are running as user services or part of
> user sessions.

 You were absolutely right, I tried to dig into that and find out as it
was using internally su,
 but now only problem remains is shutdown order.
 As I have created a dependency that rdbms.service should start after
grid.service which works perfect at boot.
But when I do shutdown / reboot both services stop simultaneously.
which i want my grid.service to wait first before rdbms.service will
stop
As Type mentioned in services are oneshot.

>dmesg output does not contain any systemd log. Anyway, we already know
>that your services are not really system services.

So my service is system services, as let me attach cgls output

└─system.slice
 ├─rdbms.service
 │ └─8039 /sarahn9db/db/11.2.0/bin/tnslsnr sarahn9 -inherit
 ├─grid.service
 │ ├─  5316 /grid/gi/11.2.0/bin/ohasd.bin reboot
 │ ├─  6159 /grid/gi/11.2.0/bin/cssdagent

On Tue, Jun 16, 2020 at 12:23 AM Andrei Borzenkov 
wrote:

> 16.06.2020 07:36, Kamal Rathi пишет:
> > The fact that you need RemainAfterExit at all hints that processes that
> > belong to your service are not running as part of service control group.
> > Knowing how Oracle has traditionally been managed, I suspect that you
> > perform "su - oracle_owner" or similar to start them in which case all
> > actual service processes become part of respective user sessions, and
> > not part of your system services. There is no way to synchronize
> > stopping of processes/services belonging to different users. They are
> > completely independent and shutdown for all sessions is initiated in
> > parallel.
> >
>
> Please take at least some efforts to format mail so that it can be
> properly understood. Otherwise I am afraid your mails will simply be
> ignored.
>
> > If my theory is correct, the fix would be to actually run your systemd
> > services as systemd services. If my theory is wrong, provide full from
> > system boot to shutdown where it could be seen how your services are
> > started/stopped. Enabling systemd debug log level when doing it
> > certainly won't harm.
> >
> >
> >
> > I have incorporated Type=oneshot and remainAfterExit=yes as it was
> helpful
> > in startup of services,
>
>
> How RemainAfterExit affects *startup* of services?
>
> > but still grid.service are starting up in
> > user.slice
>
> So I was right. Your programs are running as user services or part of
> user sessions.
>
> > and shutdown was giving the same results
> > I am attaching debug logs .
> >
>
> dmesg output does not contain any systemd log. Anyway, we already know
> that your services are not really system services.
>
> > On Mon, Jun 15, 2020 at 10:34 AM Andrei Borzenkov 
> > wrote:
> >
> >> 15.06.2020 11:01, Kamal Rathi пишет:
> >>> Hi Team,
> >>>
> >>> I have two services which are dependent on each other and are working
> >> fine
> >>> at boot up but at shutdown / reboot , the processes get killed as
> >> shutdown
> >>> got initated.
> >>>
> >>> Services are running fine in particular order but processes got killed
> .I
> >>> have enabled lingering on both users and changed confgiuration in
> >>> logind.conf to KillUserProcesses=no but still issue is same
> >>>
> >>
> >> Lingering/KillUserProcesses are relevant only for user services/sessions
> >> and so far there was no indication you use either.
> >>
> >>> ##
> >>> Systemd service files content are below
> >>>
> >>> cat /etc/systemd/system/grid.service
> >>> [Unit]
> >>> Description=Service to auto start Oracle ASM application
> >>> Before=rdbms.service
> >>> After=syslog.target network.target nfs-mountd.service autofs.service
> >>> systemd-user-sessions.service system.slice
> >>> [Service]
> >>> Type=simple
> >>> TimeoutSec=5min
> >>> User=grid
> >>> Group=dba
> >>> ExecStart=/opt/admin/bin/asm
> >>> ExecStop=/opt/admin/bin/asm_stop
> >>> RemainAfterExit=yes
> >>> [Install]
> >>> WantedBy=multi-user.target
> >>>
> >>>
> >>>
> >>> cat /etc/systemd/system/rdbms.service
> >>> [Unit]
> >>> Description=Service to auto start Oracle RDBMS application
> >>> Requires=grid.service
> >>> After=grid.service syslog.target network.target nfs-mountd.service
> >>> autofs.service systemd-user-sessions.service system.slice
> >>> [Service]
> >>> Type=simple
> >>> TimeoutSec=5min
> >>> User=osarahn9
> >>> Group=dba
> >>> 

Re: [systemd-devel] Systemd killed processes of custom services instead of graceful shutdown

2020-06-16 Thread Lennart Poettering
On Mo, 15.06.20 03:01, Kamal Rathi (kr30ap...@gmail.com) wrote:

> Hi Team,
>
> I have two services which are dependent on each other and are working fine
> at boot up but at shutdown / reboot , the processes get killed as shutdown
> got initated.

My educated guess is that your services use "su" or so, thus opening a
new session, which then gets killed like user sessions get killed. Use
"setpriv" to change privileges, not "su".

If "su" is not in the mix, then make sure your ExecStop= scripts work
correctly and kill all service processes correctly, since systemd just
kills what the ExecStop= binary doesn't kill.

Lennart

--
Lennart Poettering, Berlin
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Systemd killed processes of custom services instead of graceful shutdown

2020-06-15 Thread Andrei Borzenkov
16.06.2020 07:36, Kamal Rathi пишет:
> The fact that you need RemainAfterExit at all hints that processes that
> belong to your service are not running as part of service control group.
> Knowing how Oracle has traditionally been managed, I suspect that you
> perform "su - oracle_owner" or similar to start them in which case all
> actual service processes become part of respective user sessions, and
> not part of your system services. There is no way to synchronize
> stopping of processes/services belonging to different users. They are
> completely independent and shutdown for all sessions is initiated in
> parallel.
> 

Please take at least some efforts to format mail so that it can be
properly understood. Otherwise I am afraid your mails will simply be
ignored.

> If my theory is correct, the fix would be to actually run your systemd
> services as systemd services. If my theory is wrong, provide full from
> system boot to shutdown where it could be seen how your services are
> started/stopped. Enabling systemd debug log level when doing it
> certainly won't harm.
> 
> 
> 
> I have incorporated Type=oneshot and remainAfterExit=yes as it was helpful
> in startup of services,


How RemainAfterExit affects *startup* of services?

> but still grid.service are starting up in
> user.slice 

So I was right. Your programs are running as user services or part of
user sessions.

> and shutdown was giving the same results
> I am attaching debug logs .
> 

dmesg output does not contain any systemd log. Anyway, we already know
that your services are not really system services.

> On Mon, Jun 15, 2020 at 10:34 AM Andrei Borzenkov 
> wrote:
> 
>> 15.06.2020 11:01, Kamal Rathi пишет:
>>> Hi Team,
>>>
>>> I have two services which are dependent on each other and are working
>> fine
>>> at boot up but at shutdown / reboot , the processes get killed as
>> shutdown
>>> got initated.
>>>
>>> Services are running fine in particular order but processes got killed .I
>>> have enabled lingering on both users and changed confgiuration in
>>> logind.conf to KillUserProcesses=no but still issue is same
>>>
>>
>> Lingering/KillUserProcesses are relevant only for user services/sessions
>> and so far there was no indication you use either.
>>
>>> ##
>>> Systemd service files content are below
>>>
>>> cat /etc/systemd/system/grid.service
>>> [Unit]
>>> Description=Service to auto start Oracle ASM application
>>> Before=rdbms.service
>>> After=syslog.target network.target nfs-mountd.service autofs.service
>>> systemd-user-sessions.service system.slice
>>> [Service]
>>> Type=simple
>>> TimeoutSec=5min
>>> User=grid
>>> Group=dba
>>> ExecStart=/opt/admin/bin/asm
>>> ExecStop=/opt/admin/bin/asm_stop
>>> RemainAfterExit=yes
>>> [Install]
>>> WantedBy=multi-user.target
>>>
>>>
>>>
>>> cat /etc/systemd/system/rdbms.service
>>> [Unit]
>>> Description=Service to auto start Oracle RDBMS application
>>> Requires=grid.service
>>> After=grid.service syslog.target network.target nfs-mountd.service
>>> autofs.service systemd-user-sessions.service system.slice
>>> [Service]
>>> Type=simple
>>> TimeoutSec=5min
>>> User=osarahn9
>>> Group=dba
>>> ExecStart=/opt/admin/bin/rdbms
>>> ExecStop=/opt/admin/bin/rdbms_stop
>>> RemainAfterExit=yes
>>> [Install]
>>> WantedBy=multi-user.target grid.service
>>>
>>>
>>> let me know if my configuration is faulty or what I have missed so that
>>> shutdown should be graceful for services and processes will be
>>> shutdown with systemd custom service?
>>>
>>
>> You do not provide enough information (full logs would be certainly much
>> more useful than long description) so I can only give educated guess.
>>
>>> I want first rdbms.service should be called and get process stopped
>> before
>>> grid.services (it seems systemd are killing user.slices processes) and in
>>> startup-inverse should be followed .
>>> Please help .
>>>
>>
>> The fact that you need RemainAfterExit at all hints that processes that
>> belong to your service are not running as part of service control group.
>> Knowing how Oracle has traditionally been managed, I suspect that you
>> perform "su - oracle_owner" or similar to start them in which case all
>> actual service processes become part of respective user sessions, and
>> not part of your system services. There is no way to synchronize
>> stopping of processes/services belonging to different users. They are
>> completely independent and shutdown for all sessions is initiated in
>> parallel.
>>
>> If my theory is correct, the fix would be to actually run your systemd
>> services as systemd services. If my theory is wrong, provide full from
>> system boot to shutdown where it could be seen how your services are
>> started/stopped. Enabling systemd debug log level when doing it
>> certainly won't harm.
>> ___
>> systemd-devel mailing list
>> systemd-devel@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
>>
> 

Re: [systemd-devel] Systemd killed processes of custom services instead of graceful shutdown

2020-06-15 Thread Andrei Borzenkov
15.06.2020 11:01, Kamal Rathi пишет:
> Hi Team,
> 
> I have two services which are dependent on each other and are working fine
> at boot up but at shutdown / reboot , the processes get killed as shutdown
> got initated.
> 
> Services are running fine in particular order but processes got killed .I
> have enabled lingering on both users and changed confgiuration in
> logind.conf to KillUserProcesses=no but still issue is same
> 

Lingering/KillUserProcesses are relevant only for user services/sessions
and so far there was no indication you use either.

> ##
> Systemd service files content are below
> 
> cat /etc/systemd/system/grid.service
> [Unit]
> Description=Service to auto start Oracle ASM application
> Before=rdbms.service
> After=syslog.target network.target nfs-mountd.service autofs.service
> systemd-user-sessions.service system.slice
> [Service]
> Type=simple
> TimeoutSec=5min
> User=grid
> Group=dba
> ExecStart=/opt/admin/bin/asm
> ExecStop=/opt/admin/bin/asm_stop
> RemainAfterExit=yes
> [Install]
> WantedBy=multi-user.target
> 
> 
> 
> cat /etc/systemd/system/rdbms.service
> [Unit]
> Description=Service to auto start Oracle RDBMS application
> Requires=grid.service
> After=grid.service syslog.target network.target nfs-mountd.service
> autofs.service systemd-user-sessions.service system.slice
> [Service]
> Type=simple
> TimeoutSec=5min
> User=osarahn9
> Group=dba
> ExecStart=/opt/admin/bin/rdbms
> ExecStop=/opt/admin/bin/rdbms_stop
> RemainAfterExit=yes
> [Install]
> WantedBy=multi-user.target grid.service
> 
> 
> let me know if my configuration is faulty or what I have missed so that
> shutdown should be graceful for services and processes will be
> shutdown with systemd custom service?
> 

You do not provide enough information (full logs would be certainly much
more useful than long description) so I can only give educated guess.

> I want first rdbms.service should be called and get process stopped before
> grid.services (it seems systemd are killing user.slices processes) and in
> startup-inverse should be followed .
> Please help .
> 

The fact that you need RemainAfterExit at all hints that processes that
belong to your service are not running as part of service control group.
Knowing how Oracle has traditionally been managed, I suspect that you
perform "su - oracle_owner" or similar to start them in which case all
actual service processes become part of respective user sessions, and
not part of your system services. There is no way to synchronize
stopping of processes/services belonging to different users. They are
completely independent and shutdown for all sessions is initiated in
parallel.

If my theory is correct, the fix would be to actually run your systemd
services as systemd services. If my theory is wrong, provide full from
system boot to shutdown where it could be seen how your services are
started/stopped. Enabling systemd debug log level when doing it
certainly won't harm.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Systemd killed processes of custom services instead of graceful shutdown

2020-06-15 Thread Kamal Rathi
>> can you plesse only respond to the list to not break reply-to
I will use reply to all


>> useless unless you set "DefaultDependencies=no" which you shouldn't do
for normal services

>> if i remove all the service and only put After=grid.service, so it will
work similar way that how it is currently behaving correct.

so it doesn't make any difference if services will be in [Unit] section.
Even strange thing is that when  systemd-cgls as it is showing under
.user.slice, i think if service get started with systemd then it should
come under systemd.slice.
Mya be i can wrong about it as systemd is a vast subject and may be i
mis-understand something incorrectly.

I am just trying to understand and want to get some solution for my
services to be run flawlessly at boot.



On Mon, Jun 15, 2020 at 5:00 AM Reindl Harald 
wrote:

> can you plesse only respond to the list to not break reply-to
>
> Am 15.06.20 um 11:49 schrieb Kamal Rathi:
> > can you answer the question why you did put that option at all into the
> > unit file and why do you add random options to your units like
> > "After=syslog.target systemd-user-sessions.service system.slice"
> >  I have added above options so that my script will start after
> > filesystems,network and user sessions are online and should be stopped
> > before those all services so that custom service will be first at
> > shutdown or at least before user.slice killed
>
> useless unless you set "DefaultDependencies=no" which you shouldn't do
> for normal services
> ___
> systemd-devel mailing list
> systemd-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
>
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Systemd killed processes of custom services instead of graceful shutdown

2020-06-15 Thread Reindl Harald
can you plesse only respond to the list to not break reply-to

Am 15.06.20 um 11:49 schrieb Kamal Rathi:
> can you answer the question why you did put that option at all into the
> unit file and why do you add random options to your units like
> "After=syslog.target systemd-user-sessions.service system.slice"  
>  I have added above options so that my script will start after
> filesystems,network and user sessions are online and should be stopped
> before those all services so that custom service will be first at
> shutdown or at least before user.slice killed

useless unless you set "DefaultDependencies=no" which you shouldn't do
for normal services
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Systemd killed processes of custom services instead of graceful shutdown

2020-06-15 Thread Kamal Rathi
>>.what about just remove "RemainAfterExit" and look again?
I have tried the above option by removing that option and also tried to
change it to oneshot and RemainAfterexit=yes and then tried it but the
issue still remains.

can you answer the question why you did put that option at all into the
unit file and why do you add random options to your units like
"After=syslog.target systemd-user-sessions.service system.slice"
 I have added above options so that my script will start after
filesystems,network and user sessions are online and should be stopped
before those all services so that custom service will be first at shutdown
or at least before user.slice killed

On Mon, Jun 15, 2020 at 4:01 AM Reindl Harald 
wrote:

>
>
> Am 15.06.20 um 10:51 schrieb Kamal Rathi:
> > Thanks Reindl for the response, but from the man page of systemd.service
> > even oneshot is a kind of simple service as default is
> > RemainAfterExit=no for simple.
>
> simple:  long running processes
> oneshot: expected to completly exit
>
> this are completly different beasts and type simple has nothing to with
> "the service is simple"
>
> Behavior of oneshot is similar to simple; however, the service manager
> will consider the unit up after the main process exits. It will then
> start follow-up units. RemainAfterExit= is particularly useful for this
> type of service
>
> > But if we talk about the original problem that processes are killed even
> > if ordering of services is there, .
> > from what it seems that user.slice is killed before my services will
> > shut down processes gracefully.
> > I have tried also putting user.slice as After= dependency but result is
> > the same.
>
> what about just remove "RemainAfterExit" and look again?
>
> can you answer the question why you did put that option at all into the
> unit file and why do you add random options to your units like
> "After=syslog.target systemd-user-sessions.service system.slice"
>
> > On Mon, Jun 15, 2020 at 3:18 AM Reindl Harald  > > wrote:
> >
> >
> >
> > Am 15.06.20 um 10:01 schrieb Kamal Rathi:
> > > Hi Team,
> > >
> > > I have two services which are dependent on each other and are
> working
> > > fine at boot up but at shutdown / reboot , the processes get
> killed as
> > > shutdown got initated.
> > >
> > > Services are running fine in particular order but processes got
> killed
> > > .I have enabled lingering on both users and changed
> confgiuration in
> > > logind.conf to KillUserProcesses=no but still issue is same
> > >
> > > let me know if my configuration is faulty or what I have missed so
> > that
> > > shutdown should be graceful for services and processes will be
> > > shutdown with systemd custom service?
> > >
> > > I want first rdbms.service should be called and get process stopped
> > > before grid.services (it seems systemd are killing user.slices
> > > processes) and in startup-inverse should be followed .
> > > Please help
> >
> > i would start with thinking about why the useless
> "RemainAfterExit=yes"
> > is in a service with type=simple
> >
> > this is nice fot type=oneshot but makes no sense here when you want
> to
> > order things running long living processes
> >
> > RemainAfterExit=
> > Takes a boolean value that specifies whether the service shall be
> > considered active even when all its processes exited. Defaults to no.
>
> ___
> systemd-devel mailing list
> systemd-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
>
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Systemd killed processes of custom services instead of graceful shutdown

2020-06-15 Thread Reindl Harald


Am 15.06.20 um 10:51 schrieb Kamal Rathi:
> Thanks Reindl for the response, but from the man page of systemd.service
> even oneshot is a kind of simple service as default is
> RemainAfterExit=no for simple.

simple:  long running processes
oneshot: expected to completly exit

this are completly different beasts and type simple has nothing to with
"the service is simple"

Behavior of oneshot is similar to simple; however, the service manager
will consider the unit up after the main process exits. It will then
start follow-up units. RemainAfterExit= is particularly useful for this
type of service

> But if we talk about the original problem that processes are killed even
> if ordering of services is there, .
> from what it seems that user.slice is killed before my services will
> shut down processes gracefully.
> I have tried also putting user.slice as After= dependency but result is
> the same.

what about just remove "RemainAfterExit" and look again?

can you answer the question why you did put that option at all into the
unit file and why do you add random options to your units like
"After=syslog.target systemd-user-sessions.service system.slice"

> On Mon, Jun 15, 2020 at 3:18 AM Reindl Harald  > wrote:
> 
> 
> 
> Am 15.06.20 um 10:01 schrieb Kamal Rathi:
> > Hi Team,
> >
> > I have two services which are dependent on each other and are working
> > fine at boot up but at shutdown / reboot , the processes get killed as
> > shutdown got initated.
> >
> > Services are running fine in particular order but processes got killed
> > .I have enabled lingering on both users and changed confgiuration in
> > logind.conf to KillUserProcesses=no but still issue is same 
> >
> > let me know if my configuration is faulty or what I have missed so
> that
> > shutdown should be graceful for services and processes will be
> > shutdown with systemd custom service?
> >
> > I want first rdbms.service should be called and get process stopped
> > before grid.services (it seems systemd are killing user.slices
> > processes) and in startup-inverse should be followed .
> > Please help
> 
> i would start with thinking about why the useless "RemainAfterExit=yes"
> is in a service with type=simple
> 
> this is nice fot type=oneshot but makes no sense here when you want to
> order things running long living processes
> 
> RemainAfterExit=
> Takes a boolean value that specifies whether the service shall be
> considered active even when all its processes exited. Defaults to no.

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Systemd killed processes of custom services instead of graceful shutdown

2020-06-15 Thread Kamal Rathi
Thanks Reindl for the response, but from the man page of systemd.service
even oneshot is a kind of simple service as default is RemainAfterExit=no
for simple.
But if we talk about the original problem that processes are killed even if
ordering of services is there, .
from what it seems that user.slice is killed before my services will shut
down processes gracefully.
I have tried also putting user.slice as After= dependency but result is the
same.

On Mon, Jun 15, 2020 at 3:18 AM Reindl Harald 
wrote:

>
>
> Am 15.06.20 um 10:01 schrieb Kamal Rathi:
> > Hi Team,
> >
> > I have two services which are dependent on each other and are working
> > fine at boot up but at shutdown / reboot , the processes get killed as
> > shutdown got initated.
> >
> > Services are running fine in particular order but processes got killed
> > .I have enabled lingering on both users and changed confgiuration in
> > logind.conf to KillUserProcesses=no but still issue is same
> >
> > let me know if my configuration is faulty or what I have missed so that
> > shutdown should be graceful for services and processes will be
> > shutdown with systemd custom service?
> >
> > I want first rdbms.service should be called and get process stopped
> > before grid.services (it seems systemd are killing user.slices
> > processes) and in startup-inverse should be followed .
> > Please help
>
> i would start with thinking about why the useless "RemainAfterExit=yes"
> is in a service with type=simple
>
> this is nice fot type=oneshot but makes no sense here when you want to
> order things running long living processes
>
> RemainAfterExit=
> Takes a boolean value that specifies whether the service shall be
> considered active even when all its processes exited. Defaults to no.
> ___
> systemd-devel mailing list
> systemd-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
>
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Systemd killed processes of custom services instead of graceful shutdown

2020-06-15 Thread Reindl Harald


Am 15.06.20 um 10:01 schrieb Kamal Rathi:
> Hi Team,
> 
> I have two services which are dependent on each other and are working
> fine at boot up but at shutdown / reboot , the processes get killed as
> shutdown got initated.
> 
> Services are running fine in particular order but processes got killed
> .I have enabled lingering on both users and changed confgiuration in
> logind.conf to KillUserProcesses=no but still issue is same 
> 
> let me know if my configuration is faulty or what I have missed so that
> shutdown should be graceful for services and processes will be
> shutdown with systemd custom service?
> 
> I want first rdbms.service should be called and get process stopped
> before grid.services (it seems systemd are killing user.slices
> processes) and in startup-inverse should be followed .
> Please help

i would start with thinking about why the useless "RemainAfterExit=yes"
is in a service with type=simple

this is nice fot type=oneshot but makes no sense here when you want to
order things running long living processes

RemainAfterExit=
Takes a boolean value that specifies whether the service shall be
considered active even when all its processes exited. Defaults to no.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] Systemd killed processes of custom services instead of graceful shutdown

2020-06-15 Thread Kamal Rathi
Hi Team,

I have two services which are dependent on each other and are working fine
at boot up but at shutdown / reboot , the processes get killed as shutdown
got initated.

Services are running fine in particular order but processes got killed .I
have enabled lingering on both users and changed confgiuration in
logind.conf to KillUserProcesses=no but still issue is same

##
Systemd service files content are below

cat /etc/systemd/system/grid.service
[Unit]
Description=Service to auto start Oracle ASM application
Before=rdbms.service
After=syslog.target network.target nfs-mountd.service autofs.service
systemd-user-sessions.service system.slice
[Service]
Type=simple
TimeoutSec=5min
User=grid
Group=dba
ExecStart=/opt/admin/bin/asm
ExecStop=/opt/admin/bin/asm_stop
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target



cat /etc/systemd/system/rdbms.service
[Unit]
Description=Service to auto start Oracle RDBMS application
Requires=grid.service
After=grid.service syslog.target network.target nfs-mountd.service
autofs.service systemd-user-sessions.service system.slice
[Service]
Type=simple
TimeoutSec=5min
User=osarahn9
Group=dba
ExecStart=/opt/admin/bin/rdbms
ExecStop=/opt/admin/bin/rdbms_stop
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target grid.service


let me know if my configuration is faulty or what I have missed so that
shutdown should be graceful for services and processes will be
shutdown with systemd custom service?

I want first rdbms.service should be called and get process stopped before
grid.services (it seems systemd are killing user.slices processes) and in
startup-inverse should be followed .
Please help .

Regards,
Kamal Rathi
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel