[systemd-devel] Does systemctl unmask enables a service also?

2021-07-17 Thread Debraj Manna
Hi

I have read this article
 and it appears to me
that unmasking and starting a service should also enable it back. But on
trying it does not appear to happen like that

ubuntu@vrni-platform:~$ sudo systemctl status flinkjobs.service
● flinkjobs.service - Flinkjobs Service
   Loaded: loaded (/usr/lib/systemd/system/flinkjobs.service; disabled;
vendor preset: enabled)
   Active: active (running) since Sat 2021-07-17 18:27:38 UTC; 26min ago
 Main PID: 23321 (bash)
Tasks: 4 (limit: 4915)
   CGroup: /system.slice/flinkjobs.service
...

*Stopped and masked a service*

ubuntu@vrni-platform:~$ sudo service flinkjobs stop
ubuntu@vrni-platform:~$ sudo systemctl mask flinkjobs.service
Created symlink /etc/systemd/system/flinkjobs.service → /dev/null.
ubuntu@vrni-platform:~$ sudo service flinkjobs status
● flinkjobs.service
   Loaded: masked (/dev/null; bad)
   Active: inactive (dead) since Sat 2021-07-17 19:00:33 UTC; 1min 54s ago
 Main PID: 23321 (code=killed, signal=TERM)

*Unmasked and started a service*
ubuntu@vrni-platform:~$ sudo systemctl unmask flinkjobs.service
Removed /etc/systemd/system/flinkjobs.service.
ubuntu@vrni-platform:~$ sudo service flinkjobs start
ubuntu@vrni-platform:~$ sudo service flinkjobs status
● flinkjobs.service - Flinkjobs Service
   Loaded: loaded (/usr/lib/systemd/system/flinkjobs.service; disabled;
vendor preset: enabled)
   Active: active (running) since Sat 2021-07-17 19:02:53 UTC; 10s ago
 Main PID: 7958 (bash)
Tasks: 19 (limit: 4915)
   CGroup: /system.slice/flinkjobs.service
...

But if I do is-enabled it is showing the service as disabled

ubuntu@vrni-platform:~$ sudo systemctl is-enabled  flinkjobs.service
disabled

Should not unmasking and starting a service also make it enabled?

ubuntu@vrni-platform:~$ systemctl --version
systemd 237
+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP
+GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN
-PCRE2 default-hierarchy=hybrid

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


Re: [systemd-devel] Restricting swap usage for a process managed via systemd

2021-07-09 Thread Debraj Manna
Thanks Michal it worked.

On Thu, 8 Jul 2021, 21:35 Michal Koutný,  wrote:

> Hello Debraj.
>
> On Thu, Jul 08, 2021 at 05:10:44PM +0530, Debraj Manna <
> subharaj.ma...@gmail.com> wrote:
> > >> Linux vrni-platform 4.15.0-143-generic #147-Ubuntu SMP Wed Apr 14
> 16:10:11 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
> > [...]
> > GRUB_CMDLINE_LINUX="audit=1 rootdelay=180 nousb net.ifnames=0
> biosdevname=0
> > fsck.mode=force fsck.repair=yes ipv6.disable=1
> > systemd.unified_cgroup_hierarchy=1"
> >
> > Even after making these changes MemorySwapMax not taking into effect.
>
> You need to add also swapaccount=1, swap accounting is enabled by
> default only since kernel v5.8.
>
> HTH,
> Michal
>
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Restricting swap usage for a process managed via systemd

2021-07-08 Thread Debraj Manna
Thanks Mantas for replying.

I have made the below changes.

Added systemd.unified_cgroup_hierarchy=1 in /etc/default/grub ran sudo
update-grub and rebooted the node.

GRUB_CMDLINE_LINUX="audit=1 rootdelay=180 nousb net.ifnames=0 biosdevname=0
fsck.mode=force fsck.repair=yes ipv6.disable=1
systemd.unified_cgroup_hierarchy=1"

Even after making these changes MemorySwapMax not taking into effect.

support@vrni-platform:~$ cat /proc/cmdline
BOOT_IMAGE=/vmlinuz-4.15.0-143-generic root=/dev/mapper/vg-root ro
audit=1 rootdelay=180 nousb net.ifnames=0 biosdevname=0
fsck.mode=force fsck.repair=yes ipv6.disable=1
systemd.unified_cgroup_hierarchy=1 audit=1

support@vrni-platform:~$ findmnt
TARGET   SOURCE   FSTYPE OPTIONS
//dev/mapper/vg-root  ext4
rw,relatime,errors=panic,data=ordered
├─/sys   sysfssysfs
rw,nosuid,nodev,noexec,relatime
│ ├─/sys/kernel/security securityfs   securityfs
rw,nosuid,nodev,noexec,relatime
│ ├─/sys/fs/cgroup   cgroup   cgroup2
rw,nosuid,nodev,noexec,relatime,nsdelegate
│ ├─/sys/fs/pstore   pstore   pstore
rw,nosuid,nodev,noexec,relatime
│ ├─/sys/kernel/config   configfs configfs   rw,relatime
│ ├─/sys/fs/fuse/connections fusectl  fusectlrw,relatime
│ └─/sys/kernel/debugdebugfs  debugfsrw,relatime
├─/proc  proc proc
rw,nosuid,nodev,noexec,relatime
│ └─/proc/sys/fs/binfmt_misc systemd-1autofs
rw,relatime,fd=28,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=1935
├─/dev   udev devtmpfs
rw,nosuid,relatime,size=8182012k,nr_inodes=2045503,mode=755
│ ├─/dev/pts devpts   devpts
rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000
│ ├─/dev/shm tmpfstmpfs
rw,nosuid,nodev,noexec
│ ├─/dev/hugepages   hugetlbfshugetlbfs
rw,relatime,pagesize=2M
│ └─/dev/mqueue  mqueue   mqueue rw,relatime
├─/run   tmpfstmpfs
rw,nosuid,noexec,relatime,size=1642560k,mode=755
│ ├─/run/locktmpfstmpfs
rw,nosuid,nodev,noexec,relatime,size=5120k
│ ├─/run/rpc_pipefs  sunrpc   rpc_pipefs rw,relatime
│ ├─/run/shm none tmpfs
rw,nosuid,nodev,noexec,relatime
│ ├─/run/user/116tmpfstmpfs
rw,nosuid,nodev,relatime,size=1642556k,mode=700,uid=116,gid=122
│ ├─/run/user/998tmpfstmpfs
rw,nosuid,nodev,relatime,size=1642556k,mode=700,uid=998,gid=998
│ ├─/run/user/118tmpfstmpfs
rw,nosuid,nodev,relatime,size=1642556k,mode=700,uid=118,gid=124
│ ├─/run/user/1001   tmpfstmpfs
rw,nosuid,nodev,relatime,size=1642556k,mode=700,uid=1001,gid=1001
│ └─/run/user/121tmpfstmpfs
rw,nosuid,nodev,relatime,size=1642556k,mode=700,uid=121,gid=127
├─/boot  /dev/sda1ext4
rw,relatime,data=ordered
├─/tmp   /dev/mapper/vg-tmp   ext4
rw,nosuid,nodev,relatime,data=ordered
├─/home  /dev/mapper/vg-home  ext4
rw,nodev,relatime,data=ordered
└─/var   /dev/mapper/vg-var   ext4
rw,relatime,errors=panic,data=ordered
  ├─/var/log /dev/mapper/vg-var+log   ext4
rw,relatime,data=ordered
  │ └─/var/log/audit /dev/mapper/vg-var+log+audit ext4
rw,relatime,data=ordered
  └─/var/tmp /dev/mapper/vg-tmp   ext4
rw,nosuid,nodev,relatime,data=ordered
support@vrni-platform:~$

Any other suggestions?


On Mon, Jul 5, 2021 at 1:46 AM Mantas Mikulėnas  wrote:

> Looks like your Ubuntu version is using the "hybrid" cgroup mode by
> default. Cgroup v2 is indeed *enabled* in your kernel, but not necessarily
> *in use* – in the hybrid mode, systemd still mounts all resource
> controllers (cpu, memory, etc.) in v1 mode and only sets up its own process
> tracking in the v2 tree. See `findmnt`.
>
> You could boot with the systemd.unified_cgroup_hierarchy=1 kernel option
> to switch everything to cgroups v2, but if you're using container software
> (docker, podman) make sure those are cgroups v2-compatible.
>
> On Sun, Jul 4, 2021 at 10:36 AM Debraj Manna 
> wrote:
>
>> Hi
>>
>> I am trying to restrict the swap usage of a process using MemorySwapMax as
>> mentioned in the doc
>> <http://manpages.ubuntu.com/manpages/bionic/man5/systemd.resource-control.5.html>
>>  with
>&

[systemd-devel] Restricting swap usage for a process managed via systemd

2021-07-04 Thread Debraj Manna
Hi

I am trying to restrict the swap usage of a process using MemorySwapMax as
mentioned in the doc

with
Ubuntu 18.04.

Environment


ubuntu@vrni-platform:/usr/lib/systemd/system$ uname -a
Linux vrni-platform 4.15.0-143-generic #147-Ubuntu SMP Wed Apr 14
16:10:11 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

ubuntu@vrni-platform:/usr/lib/systemd/system$ systemctl --version
systemd 237
+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP
+LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS
+KMOD -IDN2 +IDN -PCRE2 default-hierarchy=hybrid

My systemd unit file looks like below

[Unit]
Description=My service
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=1
User=support
MemoryMax=2000M
KillMode=process
MemoryAccounting=true
OOMScoreAdjust=1000
MemorySwapMax=1M
ExecStart=/usr/bin/java -cp /home/support
-XX:NativeMemoryTracking=summary -Xmx1m MemoryConsumer 100 200 1

MemoryMax is working as expected but MemorySwapMax seems to be not
taking effect and I am seeing the process, MemoryConsumer still using
swap more than the one specified in MemorySwapMax,

MemorySwapMax documentation states "This setting is supported only if
the unified control group hierarchy is used and disables
MemoryLimit=."

As mentioned here  I
can see cgroup v2 enabled on my setup.

ubuntu@vrni-platform:/tmp/tuk$ sudo mount -t cgroup2 none /tmp/tuk
ubuntu@vrni-platform:/tmp/tuk$ ls -l /tmp/tuk/
total 0
-r--r--r--  1 root root 0 Jul  2 17:13 cgroup.controllers
-rw-r--r--  1 root root 0 Jul  2 17:13 cgroup.max.depth
-rw-r--r--  1 root root 0 Jul  2 17:13 cgroup.max.descendants
-rw-r--r--  1 root root 0 Jun 30 14:42 cgroup.procs
-r--r--r--  1 root root 0 Jul  2 17:13 cgroup.stat
-rw-r--r--  1 root root 0 Jul  2 17:13 cgroup.subtree_control
-rw-r--r--  1 root root 0 Jul  2 17:13 cgroup.threads
drwxr-xr-x  2 root root 0 Jun 30 14:42 init.scope
drwxr-xr-x 87 root root 0 Jul  2 15:05 system.slice
drwxr-xr-x  7 root root 0 Jun 30 15:22 user.slice
ubuntu@vrni-platform:/tmp/debraj$ sudo umount /tmp/tuk

Can someone suggest what configuration I am missing?
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Failed to activate service 'org.freedesktop.systemd1': timed out

2020-05-19 Thread Debraj Manna
Thanks Lennart for replying.

If I get you correctly we can hit this issue for both of the below cases
1. Reloading unit file via daemon-reload while the services are executing and
2. Services are active and we try to disable or mask a service without
stopping it?

I apologize if I sound too repetitive. Upgrading my linux distribution
(with latest systemd) will take some time. So trying to check if
someway I can change the way I am using systemd to bypass this issue.

On Tue, May 19, 2020 at 9:32 PM Lennart Poettering
 wrote:
>
> On Di, 19.05.20 20:47, Debraj Manna (subharaj.ma...@gmail.com) wrote:
>
> > Thanks Michael for replying and giving me the issue details.
> >
> > I am trying to understand in what scenarios we may hit this issue. I
> > checked the issue. It states that "This can happen when the
> > configuration is changed and reloaded while we are executing a
> > service.". Can you also please explain what does configuration changed
> > and reloaded mean?
> >
> > Does it mean doing some changes in systemd unit file and then
> > re-loading (via daemon-reload) it while the services are executing or
> > the services are active and we are trying to disable or do a mask
> > operation?
>
> Yes.
>
> Lennart
>
> --
> Lennart Poettering, Berlin
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Failed to activate service 'org.freedesktop.systemd1': timed out

2020-05-19 Thread Debraj Manna
Thanks Michael for replying and giving me the issue details.

I am trying to understand in what scenarios we may hit this issue. I
checked the issue. It states that "This can happen when the
configuration is changed and reloaded while we are executing a
service.". Can you also please explain what does configuration changed
and reloaded mean?

Does it mean doing some changes in systemd unit file and then
re-loading (via daemon-reload) it while the services are executing or
the services are active and we are trying to disable or do a mask
operation?

On Tue, May 19, 2020 at 1:25 PM Michael Chapman  wrote:
>
> On Mon, 18 May 2020, Debraj Manna wrote:
> > Around the same time I am seeing the below error in syslog
> >
> > May 18 08:49:24 platform3 systemd[1]: Removed slice User Slice of support.
> > May 18 08:49:27 platform3 systemd[1]: Assertion 's->type ==
> > SERVICE_ONESHOT' failed at ../src/core/service.c:1792, function
> > service_enter_start(). Aborting.
> > May 18 08:49:27 platform3 systemd[1]: Caught , dumped core as pid 
> > 15839.
> > May 18 08:49:27 platform3 systemd[1]: Freezing execution.
>
> This bug (https://github.com/systemd/systemd/issues/) was fixed in
> systemd v236.
>
> See if you can use a newer version of systemd.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Failed to activate service 'org.freedesktop.systemd1': timed out

2020-05-18 Thread Debraj Manna
Around the same time I am seeing the below error in syslog

May 18 08:49:24 platform3 systemd[1]: Removed slice User Slice of support.
May 18 08:49:27 platform3 systemd[1]: Assertion 's->type ==
SERVICE_ONESHOT' failed at ../src/core/service.c:1792, function
service_enter_start(). Aborting.
May 18 08:49:27 platform3 systemd[1]: Caught , dumped core as pid 15839.
May 18 08:49:27 platform3 systemd[1]: Freezing execution.

busctl output looks like below

ubuntu@platform3:~/logs$ busctl
NAME   PID PROCESS USER
 CONNECTIONUNIT  SESSIONDESCRIPTION
:1.1   976 systemd-logind  root
 :1.1  systemd-logind.service-  -
:1.3   971 accounts-daemon root
 :1.3  accounts-daemon.service   -  -
:1.5434  49174 systemctl   root
 :1.5434   cron.service  -  -
:1.5435  49223 systemctl   root
 :1.5435   ssh.service   -  -
:1.5436  49408 busctl  ubuntu
 :1.5436   ssh.service   -  -
:1.7  1109 unattended-upgr root
 :1.7  unattended-upgrades.se... -  -
com.ubuntu.LanguageSelector  - -   -
 (activatable) - -
org.debian.AptXapianIndex- -   -
 (activatable) - -
org.freedesktop.Accounts   971 accounts-daemon root
 :1.3  accounts-daemon.service   -  -
org.freedesktop.DBus   936 dbus-daemon messagebus
 org.freedesktop.DBus dbus.service  -  -
org.freedesktop.hostname1- -   -
 (activatable) - -
org.freedesktop.locale1  - -   -
 (activatable) - -
org.freedesktop.login1 976 systemd-logind  root
 :1.1  systemd-logind.service-  -
org.freedesktop.network1 - -   -
 (activatable) - -
org.freedesktop.resolve1 - -   -
 (activatable) - -
org.freedesktop.systemd1 - -   -
 (activatable) - -
org.freedesktop.thermald - -   -
 (activatable) - -
org.freedesktop.timedate1- -   -
 (activatable)

The issue comes once in a while. The only way I can recover the setup
is to reboot.

On Mon, May 18, 2020 at 5:17 PM Debraj Manna  wrote:
>
> Hi
>
> I am using systemd 229 on Ubuntu 16.04.6.
>
> ubuntu@platform1:~$ systemctl --version
> systemd 229
> +PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP
> +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ -LZ4 +SECCOMP +BLKID +ELFUTILS
> +KMOD -IDN
>
> But sometimes when I am trying to mask a service.  I am seeing an
> error like below.
>
> systemctl mask hadoop-hdfs-zkfc.service
> Failed to activate service 'org.freedesktop.systemd1': timed out
>
> Can someone suggest what is going wrong?
>
> Thanks,
> Debraj
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] Failed to activate service 'org.freedesktop.systemd1': timed out

2020-05-18 Thread Debraj Manna
Hi

I am using systemd 229 on Ubuntu 16.04.6.

ubuntu@platform1:~$ systemctl --version
systemd 229
+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP
+LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ -LZ4 +SECCOMP +BLKID +ELFUTILS
+KMOD -IDN

But sometimes when I am trying to mask a service.  I am seeing an
error like below.

systemctl mask hadoop-hdfs-zkfc.service
Failed to activate service 'org.freedesktop.systemd1': timed out

Can someone suggest what is going wrong?

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


[systemd-devel] How does KillSignal interact with TimeoutStopSec in systemd?

2020-04-26 Thread Debraj Manna
Can someone let me know the following about systemd service shutdown
sequence

   1.

   If I have specified KillSignal=SIGTERM then how does this interact this
   TimeoutStopSec ? Does this mean that during shutdown of service, first
   SIGTERM will be sent and if the service is still running after
   TimeoutStopSec SIGKILL will be sent (if SendSIGKILL is set to yes? I am
   asking about the case where nothing is specified in ExecStop.
   2.

   Does TimeoutStopSec take into account ExecStop and all ExecPostStop?
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] Environment Variables are not getting passed to a child script started from a service

2019-08-21 Thread Debraj Manna
I am having a unit file like below running on Ubuntu 16.04 with
systemd version 229.

[Unit]
Description=Hadoop-Yarn-Resourcemanager Service
[Service]
Type=simple
Environment=JAVA_HOME=/usr/lib/jvm/jdk1.8
Environment=YARN_USER=yarn
Environment=YARN_IDENT_STRING=yarn
Environment=YARN_PID_DIR=/var/run/hadoop-yarn
Environment=YARN_LOG_DIR=/var/log/hadoop-yarn
Environment=YARN_CONF_DIR=/etc/hadoop/conf
Environment=HADOOP_LIBEXEC_DIR=/usr/lib/hadoop/libexec
IgnoreSIGPIPE=false
ExecStart=/home/ubuntu/build-target/cdh/yarn-rm/hadoop-yarn-resourcemanager-sysd-start.sh
ExecStopPost=-/bin/bash
/home/ubuntu/build-target/cdh/yarn-rm/hadoop-yarn-resourcemanager-sysd-poststop.sh
ExecStopPost=-/bin/sleep 1
RestartSec=2s
Restart=always
[Install]
WantedBy=multi-user.target

hadoop-yarn-resourcemanager-sysd-start.sh looks like below

#!/bin/bash

echo "Running pre-steps for hadoop-yarn-resourcemanager"
sudo mkdir -p $YARN_LOG_DIR
sudo chown -R yarn:hadoop $YARN_LOG_DIR
sudo mkdir -p $YARN_PID_DIR
sudo chown yarn:yarn $YARN_PID_DIR
echo "Starting hadoop-yarn-resourcemanager"
sudo -u yarn /usr/lib/hadoop-yarn/sbin/yarn-daemon.sh start resourcemanager
sleep 3
echo "Starting health check for hadoop-yarn-resourcemanager"
/home/ubuntu/build-target/cdh/yarn-rm/hadoop-yarn-resourcemanager-sysd-health.sh
res=$?

sleep 1
exit $res

yarn-daemon.sh has code like below

#!/usr/bin/env bash

echo "debrah $YARN_LOG_DIR $HADOOP_LIBEXEC_DIR"

...


But I am observing the environment variable values are not getting
passed to yarn-daemon.sh. Below are the logs

Aug 21 16:06:14 vrni-platform systemd[1]: Stopped
Hadoop-Yarn-Resourcemanager Service.
Aug 21 16:06:14 vrni-platform systemd[1]: Started
Hadoop-Yarn-Resourcemanager Service.
Aug 21 16:06:14 vrni-platform
hadoop-yarn-resourcemanager-sysd-start.sh[12333]: + echo 'Running
pre-steps for hadoop-yarn-resourcemanager'
Aug 21 16:06:14 vrni-platform
hadoop-yarn-resourcemanager-sysd-start.sh[12333]: Running pre-steps
for hadoop-yarn-resourcemanager
Aug 21 16:06:14 vrni-platform
hadoop-yarn-resourcemanager-sysd-start.sh[12333]: + sudo mkdir -p
/var/log/hadoop-yarn
Aug 21 16:06:14 vrni-platform
hadoop-yarn-resourcemanager-sysd-start.sh[12333]: + sudo chown -R
yarn:hadoop /var/log/hadoop-yarn
Aug 21 16:06:14 vrni-platform
hadoop-yarn-resourcemanager-sysd-start.sh[12333]: + sudo mkdir -p
/var/run/hadoop-yarn
Aug 21 16:06:14 vrni-platform
hadoop-yarn-resourcemanager-sysd-start.sh[12333]: + sudo chown
yarn:yarn /var/run/hadoop-yarn
Aug 21 16:06:14 vrni-platform
hadoop-yarn-resourcemanager-sysd-start.sh[12333]: + echo 'Starting
hadoop-yarn-resourcemanager'
Aug 21 16:06:14 vrni-platform
hadoop-yarn-resourcemanager-sysd-start.sh[12333]: Starting
hadoop-yarn-resourcemanager
Aug 21 16:06:14 vrni-platform
hadoop-yarn-resourcemanager-sysd-start.sh[12333]: + sudo -u yarn
/usr/lib/hadoop-yarn/sbin/yarn-daemon.sh start resourcemanager
Aug 21 16:06:14 vrni-platform
hadoop-yarn-resourcemanager-sysd-start.sh[12333]: debrah

Can someone let me know what is the correct way to declare the enviroment
variable so that it gets passed to a child script started by a systemd
service?
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

Re: [systemd-devel] Health check for a service managed by systemd

2019-07-26 Thread Debraj Manna
Thanks Mantas and Reindl for all your suggestions.

On Fri, Jul 26, 2019 at 7:29 PM Reindl Harald 
wrote:

>
>
> Am 26.07.19 um 15:37 schrieb Debraj Manna:
> > Thanks Reindl for replying.
> >
> > Can we make use of the watchdog & systemd-notify functionality of
> > systemd? I mean something like this.
>
> probably you can but i doubt you gain anything
>
> you just increase complexity with additional points of errors and i
> don't see the point when you have to use curl in both cases where the
> difference to just call "systemctl condrestart" is
>
> write a nice logline with 'logger' and the same wording as a failed
> service, i do that because a cronjob collects all that events systemwide
> to trigger cron mails
>
> don't forget 'condrestart' because it's not funny when you stop a
> service by purpose and some monitoring fires it up unasked, been there
> with mysqld 10 years ago.
>
> that below is part of my httpd rpm and works like a charme for years and
> "$max_fail_count = 3" with the sleep is important in the real world
> because when you are under load and temporary out of workers it's not
> funny when some "crap" restarts the webserver and reset the PHP bytecode
> cache all the time
>
> -
>
> [root@testserver:~]$ systemctl status monitor-httpd
> ● monitor-httpd.service - Monitor/Restart Webserver
>Loaded: loaded (/usr/lib/systemd/system/monitor-httpd.service;
> enabled; vendor preset: disabled)
>Active: active (running) since Thu 2019-07-25 04:48:57 CEST; 1 day
> 11h ago
>  Main PID: 821 (php)
> Tasks: 1 (limit: 512)
>Memory: 3.7M
>CGroup: /system.slice/monitor-httpd.service
>└─821 /usr/bin/php -n -d display_errors=1 -d
> display_startup_errors=1 /usr/bin/monitor-httpd.php
> https://rhsoft.testserver.rhsoft.net/robots.txt
>
> -
>
> [root@testserver:~]$ cat /usr/lib/systemd/system/monitor-httpd.service
> [Unit]
> Description=Monitor/Restart Webserver
> After=httpd.service network-online.target
> Requires=network-online.target
> ConditionPathExists=/etc/sysconfig/monitor-httpd
> ConditionPathExists=/usr/bin/monitor-httpd.php
> ConditionPathExists=/usr/bin/php
>
> [Service]
> Type=simple
> EnvironmentFile=/etc/sysconfig/monitor-httpd
> ExecStart=/usr/bin/php -n -d display_errors=1 -d
> display_startup_errors=1 /usr/bin/monitor-httpd.php $MONITOR_URL
>
> Restart=always
> RestartSec=5
> TimeoutSec=5
>
> User=root
> Group=root
>
> CapabilityBoundingSet=CAP_KILL
> MemoryDenyWriteExecute=yes
> NoNewPrivileges=yes
> PrivateDevices=yes
> PrivateTmp=yes
> ProtectControlGroups=yes
> ProtectHome=yes
> ProtectKernelModules=yes
> ProtectKernelTunables=yes
> ProtectSystem=strict
>
> [Install]
> WantedBy=multi-user.target
>
> -
>
> [root@testserver:~]$ cat /etc/sysconfig/monitor-httpd
> MONITOR_URL=https://rhsoft.testserver.rhsoft.net/robots.txt
>
> -
>
> [root@testserver:~]$ cat /usr/bin/monitor-httpd.php
> #!/usr/bin/php
>  /** make sure we are running as shell-script */
> if(PHP_SAPI !== 'cli')
> {
>  exit("FORBIDDEN\n");
> }
>
> /** we need at test-url as param */
> if(empty($_SERVER['argv'][1]))
> {
>  exit("USAGE: monitor-httpd.php \n");
> }
>
> /** do not verify certificates */
> stream_context_set_default(['ssl'=>['verify_peer'=>FALSE,
> 'verify_peer_name'=>FALSE, 'allow_self_signed'=>TRUE]]);
>
> /** lower default timeouts */
> ini_set('default_socket_timeout', '5');
>
> /** init vars */
> $max_fail_count = 3;
> $fail_count = 0;
> $last_restart   = 0;
>
> /** service loop */
> while(true)
> {
>  if(check_service() !== TRUE)
>  {
>   $fail_count++;
>   sleep(3);
>  }
>  /** avoid false positives and too fast restarts */
>  if($fail_count >= $max_fail_count && (time()-$last_restart) > 60)
>  {
>   echo __FILE__ . ": ERROR - httpd.service: Service hold-off time over,
> scheduling restart\n";
>   passthru('/usr/bin/systemctl condrestart httpd.service');
>   $fail_count   = 0;
>   $last_restart = time();
>  }
>  /** sleep 10 seconds between checks */
>  sleep(10);
> }
>
> /**
>  * check if service is available and responds
>  *
>  * @access public
>  * @return

Re: [systemd-devel] Health check for a service managed by systemd

2019-07-26 Thread Debraj Manna
Thanks Reindl for replying.

Can we make use of the watchdog & systemd-notify functionality of systemd?
I mean something like this.

[Unit]
Description=Test service
After=network.target

[Service]
Type=notify
# test.sh wrapper script to call the service
ExecStart=/opt/test/test.sh
Restart=always
RestartSec=1
TimeoutSec=5
WatchdogSec=5

[Install]
WantedBy=multi-user.target

Then in test.sh can we do something like

#!/bin/bash
trap 'kill $(jobs -p)' EXIT

# Start the actual service
/opt/test/service &
PID=$!

/bin/systemd-notify --ready
while(true); do
FAIL=0
kill -0 $PID
if [[ $? -ne 0 ]]; then FAIL=1; fi

#curl http://localhost/test/
#if [[ $? -ne 0 ]]; then FAIL=1; fi

if [[ $FAIL -eq 0 ]]; then /bin/systemd-notify WATCHDOG=1; fi

sleep 1
done


On Fri, Jul 26, 2019 at 12:27 AM Reindl Harald 
wrote:

>
>
> Am 25.07.19 um 20:38 schrieb Debraj Manna:
> > I have a service on a Ubuntu 16.04 which I use systemctl start, stop,
> > restart and status to control.
> >
> > One time the systemctl status returned active, but the application
> > "behind" the service responded http code different from 200.
> >
> > So I would like to restart the service when the http code is not 200.
> > Can some one let me know is there a way to achieve the same via systemd?
>
> nope, just write a seperate service with a little curl magic and
> "systemctl condrestart" and remember that you have to avoid premature
> restarts just because of a little load peak
> ___
> 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

[systemd-devel] Health check for a service managed by systemd

2019-07-25 Thread Debraj Manna
I have a service on a Ubuntu 16.04 which I use systemctl start, stop,
restart and status to control.

One time the systemctl status returned active, but the application "behind"
the service responded http code different from 200.

So I would like to restart the service when the http code is not 200. Can
some one let me know is there a way to achieve the same via systemd?
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

Re: [systemd-devel] Logs from a service is not showing up in journalctl but showing up in syslog

2019-07-25 Thread Debraj Manna
Thanks Mantas for replying.

ExecStartPre=-/bin/su ubuntu -c "/home/ubuntu/build-target/
kafka/kafka-systemd-prestart.sh"
ExecStart=/bin/su ubuntu -c "/home/ubuntu/build-target/
kafka/kafka-systemd-health.sh"
ExecStopPost=-/bin/bash /home/ubuntu/build-target/
kafka/kafka-systemd-poststop.sh

If I specify User= then all the scripts will be executed with that user.
Can you let me know if I only need to execute
kafka-systemd-prestart.sh and kafka-systemd-health.sh
with let's say ubuntu user and kafka-systemd-poststop.sh with root user
what is the recommended way to do this?

On Thu, Jul 25, 2019 at 4:50 PM Mantas Mikulėnas  wrote:

> On Thu, Jul 25, 2019 at 1:26 PM Debraj Manna 
> wrote:
>
>> I have unit file which looks like below. I am seeing some of the echo are
>> showing up in syslog but not in journalctl. Can someone let me know what is
>> going on?
>> systemd version 229 running on Ubuntu 16.
>>
>> [Unit]
>> Description=Kafka Service
>>
>> [Service]
>> Type=simple
>> Environment=KAFKA_HOME=/home/ubuntu/deploy/kafka
>> Environment=LIB_DIR=/var/lib/kafka
>> Environment=LOG_DIR=/var/log/kafka
>> Environment=TEMP_DIR=/home/ubuntu/tmp
>>
>> Environment=TOOLS_JAR=/home/ubuntu/build-target/common-utils/tools-0.001-SNAPSHOT.jar
>> Environment=MIN_DATA_PARTITION_FREE_SPACE_PCT=10
>> Environment=MIN_DATA_PARTITION_FREE_SPACE_GB=10
>> Environment=DATA_PARTITION_NAME=/var
>>
>> ExecStartPre=-/bin/mkdir -p /var/log/kafka
>> ExecStartPre=-/bin/chown -R ubuntu:ubuntu /var/log/kafka
>> ExecStartPre=-/bin/mkdir -p /var/lib/kafka/kafka-logs
>> ExecStartPre=-/bin/chown -R ubuntu:ubuntu /var/lib/kafka/kafka-logs
>> ExecStartPre=-/bin/rm -f /var/log/kafka/kafka-logs/.lock
>> ExecStartPre=-/bin/mkdir -p /home/ubuntu/tmp
>> ExecStartPre=-/bin/chown -R ubuntu:ubuntu /home/ubuntu/tmp
>> ExecStartPre=-/bin/chmod -R 775 /home/ubuntu/tmp
>> ExecStartPre=-/bin/su ubuntu -c
>> "/home/ubuntu/build-target/kafka/kafka-systemd-prestart.sh"
>> ExecStart=/bin/su ubuntu -c
>> "/home/ubuntu/build-target/kafka/kafka-systemd-health.sh"
>>
>> [...]
>
>> Doing sudo journalctl -u kafka.service looks like below
>>
>> Jul 25 07:41:39 platform2 systemd[1]: Started Kafka Service.
>> Jul 25 07:41:39 platform2 su[39160]: Successful su for ubuntu by root
>> Jul 25 07:41:39 platform2 su[39160]: + ??? root:ubuntu
>> Jul 25 07:41:39 platform2 su[39160]: pam_unix(su:session): session opened 
>> for user ubuntu by (uid=0)
>> Jul 25 07:41:40 platform2 bash[39192]: [Jul 25 2019 07:41:40-572] Exiting 
>> kafka...
>>
>> I am not seeing some of the echo from kafka-systemd-prestart.sh in journatl 
>> but I am seeing those logs in syslog
>>
>> Jul 25 10:17:03 platform2 su[38464]: WatchedEvent state:SyncConnected 
>> type:None path:null
>> Jul 25 10:17:03 platform2 su[38464]: Node does not exist: /brokers/ids/2
>> Jul 25 10:17:03 platform2 su[38464]: [Jul 25 2019 10:17:03-343] partition 
>> /var free% 9 required% 10 freegb 134 required 10
>> Jul 25 10:17:03 platform2 su[38464]: [Jul 25 2019 10:17:03-344] Sufficient 
>> disk space is not available, sleeping for 60 seconds before exiting...
>>
>>
> Take a look at `journalctl -o verbose SYSLOG_IDENTIFIER=su _PID=38464`.
>
> I suspect the messages *are* in the journal, just not tagged with
> UNIT=kafka.service anymore. In some distros, `su` is actually configured to
> call pam_systemd and set up a new systemd-logind session – when this
> happens, the process is moved out of kafka.service into a user session
> scope, and its syslog messages are grouped accordingly.
>
> Consider replacing `su` with `runuser`, or indeed with systemd's [Service]
> User= option.
>
> --
> Mantas Mikulėnas
>
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

Re: [systemd-devel] Logs from a service is not showing up in journalctl but showing up in syslog

2019-07-25 Thread Debraj Manna
Thanks Silvio for replying. I will check your suggestions.

But it appears this is some issue with systemd version 229 as mentioned in
https://unix.stackexchange.com/a/417632

On Thu, Jul 25, 2019 at 4:09 PM Silvio Knizek  wrote:

> Am Donnerstag, den 25.07.2019, 15:55 +0530 schrieb Debraj Manna:
> > I have unit file which looks like below. I am seeing some of the echo
> > are
> > showing up in syslog but not in journalctl. Can someone let me know
> > what is
> > going on?
> > systemd version 229 running on Ubuntu 16.
> >
> > [Unit]
> > Description=Kafka Service
> >
> > [Service]
> > Type=simple
> > Environment=KAFKA_HOME=/home/ubuntu/deploy/kafka
> > Environment=LIB_DIR=/var/lib/kafka
> > Environment=LOG_DIR=/var/log/kafka
> > Environment=TEMP_DIR=/home/ubuntu/tmp
> > Environment=TOOLS_JAR=/home/ubuntu/build-target/common-utils/tools-
> > 0.001-SNAPSHOT.jar
> > Environment=MIN_DATA_PARTITION_FREE_SPACE_PCT=10
> > Environment=MIN_DATA_PARTITION_FREE_SPACE_GB=10
> > Environment=DATA_PARTITION_NAME=/var
> >
> > ExecStartPre=-/bin/mkdir -p /var/log/kafka
> > ExecStartPre=-/bin/chown -R ubuntu:ubuntu /var/log/kafka
> > ExecStartPre=-/bin/mkdir -p /var/lib/kafka/kafka-logs
> > ExecStartPre=-/bin/chown -R ubuntu:ubuntu /var/lib/kafka/kafka-logs
> > ExecStartPre=-/bin/rm -f /var/log/kafka/kafka-logs/.lock
> > ExecStartPre=-/bin/mkdir -p /home/ubuntu/tmp
> > ExecStartPre=-/bin/chown -R ubuntu:ubuntu /home/ubuntu/tmp
> > ExecStartPre=-/bin/chmod -R 775 /home/ubuntu/tmp
> > ExecStartPre=-/bin/su ubuntu -c
> > "/home/ubuntu/build-target/kafka/kafka-systemd-prestart.sh"
> > ExecStart=/bin/su ubuntu -c
> > "/home/ubuntu/build-target/kafka/kafka-systemd-health.sh"
> > ExecStopPost=-/bin/bash
> > /home/ubuntu/build-target/kafka/kafka-systemd-poststop.sh
> > RestartSec=2s
> > Restart=always
> > LimitNOFILE=65535
> > KillSignal=SIGTERM
> > SendSIGKILL=no
> > SuccessExitStatus=1 143
> >
> > [Install]
> > WantedBy=multi-user.target
> >
> > kafka-systemd-prestart.sh looks like below
> >
> > echo "[`date +"%h %d %Y %H:%M:%S-%3N"`] Starting kafka..."
> > timeout --signal=sigkill 600s java -cp "$TOOLS_JAR"
> > com.vnera.tools.kafka.KafkaIndexValidator "$LIB_DIR/kafka-logs"
> > "$KAFKA_HOME/config/server.properties" true
> > broker_id=`sudo grep -F "broker.id"
> > $KAFKA_HOME/config/server.properties | awk -F '=' '{print $2}'`
> > zookeeper_list=`sudo grep -F "zookeeper.connect="
> > $KAFKA_HOME/config/server.properties | awk -F '=' '{print $2}'`
> > echo "attempting removal of broker id $broker_id"
> >
> > used_pct=`df ${DATA_PARTITION_NAME} --output=pcent | grep -v Use |
> > grep -o '[^ ]*[^ %]'`
> > free_pct=$(expr 100 - $used_pct)
> > free_gb=`df -h ${DATA_PARTITION_NAME} --output=avail --block-size G |
> > grep -v Avail | grep -o '[^ ]*[^ G]'`
> > echo "[`date +"%h %d %Y %H:%M:%S-%3N"`] partition
> > ${DATA_PARTITION_NAME} free% $free_pct required%
> > ${MIN_DATA_PARTITION_FREE_SPACE_PCT} freegb ${free_gb} required
> > ${MIN_DATA_PARTITION_FREE_SPACE_GB}"
> >
> > # Some other code
> >
> > kafka-systemd-poststop.sh looks like below
> >
> > ---
> >
> > echo "[`date +"%h %d %Y %H:%M:%S-%3N"`] Exiting kafka..."
> > cmd="ps -ef | grep -v grep | grep kafkaServer"
> >
> > # Some other code
> >
> > echo "completed exiting kafka"
> >
> > Doing sudo journalctl -u kafka.service looks like below
> >
> > Jul 25 07:41:39 platform2 systemd[1]: Started Kafka Service.
> > Jul 25 07:41:39 platform2 su[39160]: Successful su for ubuntu by root
> > Jul 25 07:41:39 platform2 su[39160]: + ??? root:ubuntu
> > Jul 25 07:41:39 platform2 su[39160]: pam_unix(su:session): session
> > opened for user ubuntu by (uid=0)
> > Jul 25 07:41:40 platform2 bash[39192]: [Jul 25 2019 07:41:40-572]
> > Exiting kafka...
> >
> > I am not seeing some of the echo from kafka-systemd-prestart.sh in
> > journatl but I am seeing those logs in syslog
> >
> > Jul 25 10:17:03 platform2 su[38464]: WatchedEvent state:SyncConnected
> > type:None path:null
> > Jul 25 10:17:03 platform2 su[38464]: Node does not exist:
> > /brokers/ids/2
> > Jul 25 10:17:03 platform2 su[38464]: [Jul 25 2019 10:17:03-343]
> > partition /var free% 9 required% 10 

[systemd-devel] Logs from a service is not showing up in journalctl but showing up in syslog

2019-07-25 Thread Debraj Manna
I have unit file which looks like below. I am seeing some of the echo are
showing up in syslog but not in journalctl. Can someone let me know what is
going on?
systemd version 229 running on Ubuntu 16.

[Unit]
Description=Kafka Service

[Service]
Type=simple
Environment=KAFKA_HOME=/home/ubuntu/deploy/kafka
Environment=LIB_DIR=/var/lib/kafka
Environment=LOG_DIR=/var/log/kafka
Environment=TEMP_DIR=/home/ubuntu/tmp
Environment=TOOLS_JAR=/home/ubuntu/build-target/common-utils/tools-0.001-SNAPSHOT.jar
Environment=MIN_DATA_PARTITION_FREE_SPACE_PCT=10
Environment=MIN_DATA_PARTITION_FREE_SPACE_GB=10
Environment=DATA_PARTITION_NAME=/var

ExecStartPre=-/bin/mkdir -p /var/log/kafka
ExecStartPre=-/bin/chown -R ubuntu:ubuntu /var/log/kafka
ExecStartPre=-/bin/mkdir -p /var/lib/kafka/kafka-logs
ExecStartPre=-/bin/chown -R ubuntu:ubuntu /var/lib/kafka/kafka-logs
ExecStartPre=-/bin/rm -f /var/log/kafka/kafka-logs/.lock
ExecStartPre=-/bin/mkdir -p /home/ubuntu/tmp
ExecStartPre=-/bin/chown -R ubuntu:ubuntu /home/ubuntu/tmp
ExecStartPre=-/bin/chmod -R 775 /home/ubuntu/tmp
ExecStartPre=-/bin/su ubuntu -c
"/home/ubuntu/build-target/kafka/kafka-systemd-prestart.sh"
ExecStart=/bin/su ubuntu -c
"/home/ubuntu/build-target/kafka/kafka-systemd-health.sh"
ExecStopPost=-/bin/bash
/home/ubuntu/build-target/kafka/kafka-systemd-poststop.sh
RestartSec=2s
Restart=always
LimitNOFILE=65535
KillSignal=SIGTERM
SendSIGKILL=no
SuccessExitStatus=1 143

[Install]
WantedBy=multi-user.target

kafka-systemd-prestart.sh looks like below

echo "[`date +"%h %d %Y %H:%M:%S-%3N"`] Starting kafka..."
timeout --signal=sigkill 600s java -cp "$TOOLS_JAR"
com.vnera.tools.kafka.KafkaIndexValidator "$LIB_DIR/kafka-logs"
"$KAFKA_HOME/config/server.properties" true
broker_id=`sudo grep -F "broker.id"
$KAFKA_HOME/config/server.properties | awk -F '=' '{print $2}'`
zookeeper_list=`sudo grep -F "zookeeper.connect="
$KAFKA_HOME/config/server.properties | awk -F '=' '{print $2}'`
echo "attempting removal of broker id $broker_id"

used_pct=`df ${DATA_PARTITION_NAME} --output=pcent | grep -v Use |
grep -o '[^ ]*[^ %]'`
free_pct=$(expr 100 - $used_pct)
free_gb=`df -h ${DATA_PARTITION_NAME} --output=avail --block-size G |
grep -v Avail | grep -o '[^ ]*[^ G]'`
echo "[`date +"%h %d %Y %H:%M:%S-%3N"`] partition
${DATA_PARTITION_NAME} free% $free_pct required%
${MIN_DATA_PARTITION_FREE_SPACE_PCT} freegb ${free_gb} required
${MIN_DATA_PARTITION_FREE_SPACE_GB}"

# Some other code

kafka-systemd-poststop.sh looks like below

---

echo "[`date +"%h %d %Y %H:%M:%S-%3N"`] Exiting kafka..."
cmd="ps -ef | grep -v grep | grep kafkaServer"

# Some other code

echo "completed exiting kafka"

Doing sudo journalctl -u kafka.service looks like below

Jul 25 07:41:39 platform2 systemd[1]: Started Kafka Service.
Jul 25 07:41:39 platform2 su[39160]: Successful su for ubuntu by root
Jul 25 07:41:39 platform2 su[39160]: + ??? root:ubuntu
Jul 25 07:41:39 platform2 su[39160]: pam_unix(su:session): session
opened for user ubuntu by (uid=0)
Jul 25 07:41:40 platform2 bash[39192]: [Jul 25 2019 07:41:40-572]
Exiting kafka...

I am not seeing some of the echo from kafka-systemd-prestart.sh in
journatl but I am seeing those logs in syslog

Jul 25 10:17:03 platform2 su[38464]: WatchedEvent state:SyncConnected
type:None path:null
Jul 25 10:17:03 platform2 su[38464]: Node does not exist: /brokers/ids/2
Jul 25 10:17:03 platform2 su[38464]: [Jul 25 2019 10:17:03-343]
partition /var free% 9 required% 10 freegb 134 required 10
Jul 25 10:17:03 platform2 su[38464]: [Jul 25 2019 10:17:03-344]
Sufficient disk space is not available, sleeping for 60 seconds before
exiting...
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

Re: [systemd-devel] How to ensure a systemd unit waits for ntpd to sync before starting?

2019-04-02 Thread Debraj Manna
Thanks again for all the replies.

I am on Ubuntu 16.04 which is using systemd version 239. It appears to me
that systemd-time-wait-sync.service is not present on this version of
systemd.

I have one more question related to this. If I switch to using systemd's
timesyncd.service then in my service unit file I can use

After=time-sync.target
Wants=time-sync.target

Can someone let me know for how long will the unit wait for ntp sync to
happen before giving up ? Is there a way I can control this?

On Tue, Apr 2, 2019 at 6:51 PM Lennart Poettering 
wrote:

> On Di, 02.04.19 12:53, Marc Haber (mh+systemd-de...@zugschlus.de) wrote:
>
> > On Tue, Apr 02, 2019 at 12:32:58PM +0200, Lennart Poettering wrote:
> > > I thought people have noticed by now that systemd is really about
> > > removing unnecessary shell scripts from all clean system boot
> > > codepaths.
> >
> > The problem is that millions of professional systems administrators do
> > violently disagree.
>
> Right.
>
> > I have seen unit files full of bash -c and quoting hell. Your work. Be
> > proud of it.
>
> Hmm? if you want to run a shell script from a .service file, you are
> welcome to. Not sure why you would squish a shell script into
> bash -c line. I mean, if you want a shell script, use a shell script,
> there's nothing wrong with that.
>
> Anyway, I think you fundamentally disagree with the approach we took
> of having declarative unit files describing services instead of having
> Turing complete programming languages for everything. At this point
> that discussion is moot, and you are not going to convince us
> anyway. Moreover it's off-topic to this mail list thread, hence please
> let's end this subthread here. Thank you for understanding.
>
> Lennart
>
> --
> Lennart Poettering, Berlin
> ___
> 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] How to ensure a systemd unit waits for ntpd to sync before starting?

2019-04-02 Thread Debraj Manna
Thanks again for all the replies.

I am on Ubuntu 16.04 which is using systemd version 239. It appears to me
that systemd-time-wait-sync.service is not present on this version of
systemd.

I have one more question related to this. If I switch to using systemd's
timesyncd.service then in my service unit file I can use

After=time-sync.target
Wants=time-sync.target

Can someone let me know for how long will the unit wait for ntp sync to
happen before giving up ? Is there a way we can control this?

On Tue, Apr 2, 2019 at 4:24 PM Marc Haber 
wrote:

> On Tue, Apr 02, 2019 at 12:32:58PM +0200, Lennart Poettering wrote:
> > I thought people have noticed by now that systemd is really about
> > removing unnecessary shell scripts from all clean system boot
> > codepaths.
>
> The problem is that millions of professional systems administrators do
> violently disagree.
>
> I have seen unit files full of bash -c and quoting hell. Your work. Be
> proud of it.
>
> Greetings
> Marc
>
> --
>
> -
> Marc Haber | "I don't trust Computers. They | Mailadresse im Header
> Leimen, Germany|  lose things."Winona Ryder | Fon: *49 6224 1600402
> Nordisch by Nature |  How to make an American Quilt | Fax: *49 6224 1600421
> ___
> 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] How to ensure a systemd unit waits for ntpd to sync before starting?

2019-04-02 Thread Debraj Manna
I do see a ntp-wait .
<https://linux.die.net/man/8/ntp-wait> Can
some one let me know what corresponding condition I should place in my
service unit file to wait for this?

On Tue, Apr 2, 2019 at 2:47 PM Debraj Manna 
wrote:

> Thanks for replying. Below is the service file for ntpd
>
> support@vrni-platform:/etc/init.d$ sudo systemctl cat ntp.service
> # /run/systemd/generator.late/ntp.service
> # Automatically generated by systemd-sysv-generator
>
> [Unit]
> Documentation=man:systemd-sysv-generator(8)
> SourcePath=/etc/init.d/ntp
> Description=LSB: Start NTP daemon
> Before=multi-user.target
> Before=multi-user.target
> Before=multi-user.target
> Before=graphical.target
> After=network-online.target
> After=remote-fs.target
> After=systemd-journald-dev-log.socket
> Wants=network-online.target
>
> [Service]
> Type=forking
> Restart=no
> TimeoutSec=5min
> IgnoreSIGPIPE=no
> KillMode=process
> GuessMainPID=no
> RemainAfterExit=yes
> ExecStart=/etc/init.d/ntp start
> ExecStop=/etc/init.d/ntp stop
>
>
>
> On Tue, Apr 2, 2019 at 1:48 PM Lennart Poettering 
> wrote:
>
>> On Di, 02.04.19 10:05, Reindl Harald (h.rei...@thelounge.net) wrote:
>>
>> > Am 02.04.19 um 09:44 schrieb Debraj Manna:
>> > >
>> > >   We have a service that starts at boot. We need to ensure it doesn't
>> > >   start until the system clock has been synchronized via ntp. The
>> > >   machines are using |ntpd|
>> >
>> > After=ntpd.service
>> > Wants=ntpd.service
>>
>> I don't know ntpd. But I surely hope that just starting ntpd will
>> delay boot-up until a sync is reached. If it does, then this would be
>> a bug and a misdesign in the ntpd unit files.
>>
>> (See my other mail how ntpd should do this correctly.)
>>
>> Lennart
>>
>> --
>> Lennart Poettering, Berlin
>> ___
>> 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] How to ensure a systemd unit waits for ntpd to sync before starting?

2019-04-02 Thread Debraj Manna
Thanks for replying. Below is the service file for ntpd

support@vrni-platform:/etc/init.d$ sudo systemctl cat ntp.service
# /run/systemd/generator.late/ntp.service
# Automatically generated by systemd-sysv-generator

[Unit]
Documentation=man:systemd-sysv-generator(8)
SourcePath=/etc/init.d/ntp
Description=LSB: Start NTP daemon
Before=multi-user.target
Before=multi-user.target
Before=multi-user.target
Before=graphical.target
After=network-online.target
After=remote-fs.target
After=systemd-journald-dev-log.socket
Wants=network-online.target

[Service]
Type=forking
Restart=no
TimeoutSec=5min
IgnoreSIGPIPE=no
KillMode=process
GuessMainPID=no
RemainAfterExit=yes
ExecStart=/etc/init.d/ntp start
ExecStop=/etc/init.d/ntp stop



On Tue, Apr 2, 2019 at 1:48 PM Lennart Poettering 
wrote:

> On Di, 02.04.19 10:05, Reindl Harald (h.rei...@thelounge.net) wrote:
>
> > Am 02.04.19 um 09:44 schrieb Debraj Manna:
> > >
> > >   We have a service that starts at boot. We need to ensure it doesn't
> > >   start until the system clock has been synchronized via ntp. The
> > >   machines are using |ntpd|
> >
> > After=ntpd.service
> > Wants=ntpd.service
>
> I don't know ntpd. But I surely hope that just starting ntpd will
> delay boot-up until a sync is reached. If it does, then this would be
> a bug and a misdesign in the ntpd unit files.
>
> (See my other mail how ntpd should do this correctly.)
>
> Lennart
>
> --
> Lennart Poettering, Berlin
> ___
> 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

[systemd-devel] How to ensure a systemd unit waits for ntpd to sync before starting?

2019-04-02 Thread Debraj Manna
We have a service that starts at boot. We need to ensure it doesn't start
until the system clock has been synchronized via ntp. The machines are
using ntpd.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel