<div dir="ltr">>Please take at least some efforts to format mail so that it can be<br>>properly understood. Otherwise I am afraid your mails will simply be<br>>ignored.<br><br> I am sorry for inconvenience, i will try to follow correct approach afterwards while replying<br> <br>> How RemainAfterExit affects *startup* of services?<br> <br> The services worked as expected and as i fixed the issue where it was using su in script. <br> As in background there was SysVinit script which was getting invoked when system boot and makes processes falls in users.slice<br> So the startup is working perfectly after disabling that SysVinit script.<br><br>>So I was right. Your programs are running as user services or part of<br>> user sessions.<br><br> You were absolutely right, I tried to dig into that and find out as it was using internally su,<br> but now only problem remains is shutdown order. <br> As I have created a dependency that rdbms.service should start after grid.service which works perfect at boot. <br> But when I do shutdown / reboot both services stop simultaneously.<br> which i want my grid.service to wait first before rdbms.service will stop<br> As Type mentioned in services are oneshot.<br><br>>dmesg output does not contain any systemd log. Anyway, we already know<br>>that your services are not really system services.<br><br> So my service is system services, as let me attach cgls output <br><br> └─system.slice<br> ├─rdbms.service<br> │ └─8039 /sarahn9db/db/11.2.0/bin/tnslsnr sarahn9 -inherit<br> ├─grid.service<br> │ ├─ 5316 /grid/gi/11.2.0/bin/ohasd.bin reboot<br> │ ├─ 6159 /grid/gi/11.2.0/bin/cssdagent<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jun 16, 2020 at 12:23 AM Andrei Borzenkov <<a href="mailto:arvidjaar@gmail.com">arvidjaar@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">16.06.2020 07:36, Kamal Rathi пишет:<br>
> The fact that you need RemainAfterExit at all hints that processes that<br>
> belong to your service are not running as part of service control group.<br>
> Knowing how Oracle has traditionally been managed, I suspect that you<br>
> perform "su - oracle_owner" or similar to start them in which case all<br>
> actual service processes become part of respective user sessions, and<br>
> not part of your system services. There is no way to synchronize<br>
> stopping of processes/services belonging to different users. They are<br>
> completely independent and shutdown for all sessions is initiated in<br>
> parallel.<br>
> <br>
<br>
Please take at least some efforts to format mail so that it can be<br>
properly understood. Otherwise I am afraid your mails will simply be<br>
ignored.<br>
<br>
> If my theory is correct, the fix would be to actually run your systemd<br>
> services as systemd services. If my theory is wrong, provide full from<br>
> system boot to shutdown where it could be seen how your services are<br>
> started/stopped. Enabling systemd debug log level when doing it<br>
> certainly won't harm.<br>
> <br>
> <br>
> <br>
> I have incorporated Type=oneshot and remainAfterExit=yes as it was helpful<br>
> in startup of services,<br>
<br>
<br>
How RemainAfterExit affects *startup* of services?<br>
<br>
> but still grid.service are starting up in<br>
> user.slice <br>
<br>
So I was right. Your programs are running as user services or part of<br>
user sessions.<br>
<br>
> and shutdown was giving the same results<br>
> I am attaching debug logs .<br>
> <br>
<br>
dmesg output does not contain any systemd log. Anyway, we already know<br>
that your services are not really system services.<br>
<br>
> On Mon, Jun 15, 2020 at 10:34 AM Andrei Borzenkov <<a href="mailto:arvidjaar@gmail.com" target="_blank">arvidjaar@gmail.com</a>><br>
> wrote:<br>
> <br>
>> 15.06.2020 11:01, Kamal Rathi пишет:<br>
>>> Hi Team,<br>
>>><br>
>>> I have two services which are dependent on each other and are working<br>
>> fine<br>
>>> at boot up but at shutdown / reboot , the processes get killed as<br>
>> shutdown<br>
>>> got initated.<br>
>>><br>
>>> Services are running fine in particular order but processes got killed .I<br>
>>> have enabled lingering on both users and changed confgiuration in<br>
>>> logind.conf to KillUserProcesses=no but still issue is same<br>
>>><br>
>><br>
>> Lingering/KillUserProcesses are relevant only for user services/sessions<br>
>> and so far there was no indication you use either.<br>
>><br>
>>> ##############<br>
>>> Systemd service files content are below<br>
>>><br>
>>> cat /etc/systemd/system/grid.service<br>
>>> [Unit]<br>
>>> Description=Service to auto start Oracle ASM application<br>
>>> Before=rdbms.service<br>
>>> After=syslog.target network.target nfs-mountd.service autofs.service<br>
>>> systemd-user-sessions.service system.slice<br>
>>> [Service]<br>
>>> Type=simple<br>
>>> TimeoutSec=5min<br>
>>> User=grid<br>
>>> Group=dba<br>
>>> ExecStart=/opt/admin/bin/asm<br>
>>> ExecStop=/opt/admin/bin/asm_stop<br>
>>> RemainAfterExit=yes<br>
>>> [Install]<br>
>>> WantedBy=multi-user.target<br>
>>><br>
>>><br>
>>><br>
>>> cat /etc/systemd/system/rdbms.service<br>
>>> [Unit]<br>
>>> Description=Service to auto start Oracle RDBMS application<br>
>>> Requires=grid.service<br>
>>> After=grid.service syslog.target network.target nfs-mountd.service<br>
>>> autofs.service systemd-user-sessions.service system.slice<br>
>>> [Service]<br>
>>> Type=simple<br>
>>> TimeoutSec=5min<br>
>>> User=osarahn9<br>
>>> Group=dba<br>
>>> ExecStart=/opt/admin/bin/rdbms<br>
>>> ExecStop=/opt/admin/bin/rdbms_stop<br>
>>> RemainAfterExit=yes<br>
>>> [Install]<br>
>>> WantedBy=multi-user.target grid.service<br>
>>><br>
>>><br>
>>> let me know if my configuration is faulty or what I have missed so that<br>
>>> shutdown should be graceful for services and processes will be<br>
>>> shutdown with systemd custom service?<br>
>>><br>
>><br>
>> You do not provide enough information (full logs would be certainly much<br>
>> more useful than long description) so I can only give educated guess.<br>
>><br>
>>> I want first rdbms.service should be called and get process stopped<br>
>> before<br>
>>> grid.services (it seems systemd are killing user.slices processes) and in<br>
>>> startup-inverse should be followed .<br>
>>> Please help .<br>
>>><br>
>><br>
>> The fact that you need RemainAfterExit at all hints that processes that<br>
>> belong to your service are not running as part of service control group.<br>
>> Knowing how Oracle has traditionally been managed, I suspect that you<br>
>> perform "su - oracle_owner" or similar to start them in which case all<br>
>> actual service processes become part of respective user sessions, and<br>
>> not part of your system services. There is no way to synchronize<br>
>> stopping of processes/services belonging to different users. They are<br>
>> completely independent and shutdown for all sessions is initiated in<br>
>> parallel.<br>
>><br>
>> If my theory is correct, the fix would be to actually run your systemd<br>
>> services as systemd services. If my theory is wrong, provide full from<br>
>> system boot to shutdown where it could be seen how your services are<br>
>> started/stopped. Enabling systemd debug log level when doing it<br>
>> certainly won't harm.<br>
>> _______________________________________________<br>
>> systemd-devel mailing list<br>
>> <a href="mailto:systemd-devel@lists.freedesktop.org" target="_blank">systemd-devel@lists.freedesktop.org</a><br>
>> <a href="https://lists.freedesktop.org/mailman/listinfo/systemd-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/systemd-devel</a><br>
>><br>
> <br>
> <br>
> _______________________________________________<br>
> systemd-devel mailing list<br>
> <a href="mailto:systemd-devel@lists.freedesktop.org" target="_blank">systemd-devel@lists.freedesktop.org</a><br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/systemd-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/systemd-devel</a><br>
> <br>
<br>
_______________________________________________<br>
systemd-devel mailing list<br>
<a href="mailto:systemd-devel@lists.freedesktop.org" target="_blank">systemd-devel@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/systemd-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/systemd-devel</a><br>
</blockquote></div>