Use pidfile for services
Currently when we start the service we use podman start -a when we start the service so systemd monitors that process for the service. The problem is that this leaves podman start processes around which have a bunch of threads and is attached to the STDOUT/STDIN. Rather than leaving this start process around, let's switch to a forking type in system and specify a conmon pidfile for monitoring the container. This removes 500+ threads from the system. Change-Id: Ie9225ce484b94b7fd59036168aaae58f25f1589d Co-Authored-By: Emilien Macchi <emilien@redhat.com>
This commit is contained in:
parent
6e99f2e233
commit
825acc5772
|
@ -24,6 +24,10 @@ class PodmanBuilder(base.BaseBuilder):
|
|||
|
||||
def container_run_args(self, cmd, container):
|
||||
cconfig = self.config[container]
|
||||
|
||||
# write out a pid file so we can restart the container via systemd
|
||||
cmd.append('--conmon-pidfile=/var/run/{}.pid'.format(container))
|
||||
|
||||
if cconfig.get('detach', True):
|
||||
cmd.append('--detach=true')
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ class TestPodmanBuilder(base.TestBaseBuilder):
|
|||
builder.container_run_args(cmd, 'one')
|
||||
self.assertEqual(
|
||||
['podman', 'run', '--name', 'one',
|
||||
'--conmon-pidfile=/var/run/one.pid',
|
||||
'--detach=true', '--env-file=/tmp/foo.env',
|
||||
'--net=host', '--ipc=host', '--pid=container:bar',
|
||||
'--uts=host', '--privileged=true', '--user=bar',
|
||||
|
|
|
@ -38,6 +38,7 @@ class TestUtilsSystemd(base.TestCase):
|
|||
self.assertIn('Wants=something.service', unit)
|
||||
self.assertIn('Restart=always', unit)
|
||||
self.assertIn('ExecStop=/usr/bin/podman stop -t 15 my_app', unit)
|
||||
self.assertIn('PIDFile=/var/run/my_app.pid', unit)
|
||||
mock_chmod.assert_has_calls([mock.call(sysd_unit_f, 420)])
|
||||
|
||||
mock_subprocess_check_call.assert_has_calls([
|
||||
|
|
|
@ -80,9 +80,11 @@ After=paunch-container-shutdown.service
|
|||
Wants=%(wants)s
|
||||
[Service]
|
||||
Restart=%(restart)s
|
||||
ExecStart=/usr/bin/podman start -a %(name)s
|
||||
ExecStart=/usr/bin/podman start %(name)s
|
||||
ExecStop=/usr/bin/podman stop -t %(stop_grace_period)s %(name)s
|
||||
KillMode=none
|
||||
Type=forking
|
||||
PIDFile=/var/run/%(name)s.pid
|
||||
%(sys_exec)s
|
||||
[Install]
|
||||
WantedBy=multi-user.target""" % s_config)
|
||||
|
|
Loading…
Reference in New Issue