[systemd-devel] systemd unit to launch perl script/service launches the script but doesn't exit the unit

jen142 at promessage.com jen142 at promessage.com
Sat Nov 30 12:02:55 PST 2013


Hi

THanks for the pointers.  Using type=simple, and removing the unneeded
cmds, the unit for the 'smtpprox' perl daemon works exactly as expected!

As a next step, I'm attempting to extend the same method that just
worked to another perl-daemon -- the more complex 'amavisd'.

@ manual launch

	/usr/local/sbin/amavisd -c /usr/local/etc/amavis/amavisd.conf

it works as expected; @ logs,

		2013-11-30T11:51:22.176317-08:00 newmail amavis[7130]:
		logging initialized, log level 5, syslog: amavis.mail
		2013-11-30T11:51:22.177520-08:00 newmail amavis[7130]:
		starting. /usr/local/sbin/amavisd at
		newmail.jennielan.int amavisd-new-2.7.0-pre15
		(20110412), Unicode aware, LANG="en_US.UTF-8"
		2013-11-30T11:51:22.178205-08:00 newmail amavis[7130]:
		perl=5.018001, user=, EUID: 65 (65);  group=, EGID: 132
		132 (132 132)
		2013-11-30T11:51:22.220790-08:00 newmail amavis[7130]:
		bind to /var/lib/amavis/amavisd.sock|unix,
		127.0.0.1:10024/tcp
		2013-11-30T11:51:22.229543-08:00 newmail amavis[7131]:
		Net::Server: Process Backgrounded
		...
		2013-11-30T11:51:22.241323-08:00 newmail amavis[7131]:
		config files read: /usr/local/etc/amavis/amavisd.conf
		...
		2013-11-30T11:51:22.315172-08:00 newmail amavis[7139]:
		Net::Server: Child Preforked (7139)
		2013-11-30T11:51:22.315970-08:00 newmail amavis[7139]:
		entered child_init_hook

	ps ax | grep amavis
		7131 ?        Ss     0:00 /usr/local/sbin/amavisd
		(master)                                              
		7138 ?        S      0:00 /usr/local/sbin/amavisd
		(virgin child)                                        
		7139 ?        S      0:00 /usr/local/sbin/amavisd
		(virgin child)

Using systemd, I create a unit similar to the prior, now-working,
example,

	cat /etc/systemd/system/amavisd-custom.service
		[Unit]
		Description=amavisd Content Filter daemon
		Requires=network.target remote-fs.target
		After=network.target remote-fs.target
		Before=postfix-custom.service amavisd-custom.target

		[Service]
		Type=simple
		ExecStart=/usr/local/sbin/amavisd -c
		/usr/local/etc/amavis/amavisd.conf

		[Install]
		WantedBy=multi-user.target

	cat /etc/systemd/system/amavisd-custom.target
		[Unit]
		Description=Amavisd

but @ systemctl launch,

	systemctl start amavisd-custom.service

is starts, then immediately quits. @ logs,

	==> messages <==
	2013-11-30T11:53:33.680127-08:00 newmail systemd[1]: Starting
	amavisd Content Filter daemon...
	2013-11-30T11:53:33.681600-08:00 newmail systemd[1]: Started
	amavisd Content Filter daemon.

	==> mail <==
	2013-11-30T11:53:34.335565-08:00 newmail amavis[7164]: logging
	initialized, log level 5, syslog: amavis.mail
	2013-11-30T11:53:34.343504-08:00 newmail amavis[7164]:
	run_command: [7171] /usr/bin/uptime </dev/null 2>/dev/null
	2013-11-30T11:53:34.344251-08:00 newmail amavis[7171]:
	open_on_specific_fd: target fd0 closing, to become < /dev/null
	2013-11-30T11:53:34.344724-08:00 newmail amavis[7171]:
	open_on_specific_fd: target fd1 closing, to become > &=5
	2013-11-30T11:53:34.345115-08:00 newmail amavis[7171]:
	open_on_specific_fd: target fd1 dup2 from fd5 > &=5
	2013-11-30T11:53:34.345501-08:00 newmail amavis[7171]:
	open_on_specific_fd: source fd5 closed
	2013-11-30T11:53:34.345917-08:00 newmail amavis[7171]:
	open_on_specific_fd: target fd2 closing, to become > /dev/null
	2013-11-30T11:53:34.349976-08:00 newmail amavis[7164]: system
	uptime 0 0:33:00:  11:53am  up   0:33,  2 users,  load average:
	0.00, 0.02, 0.05
	2013-11-30T11:53:34.350503-08:00 newmail amavis[7164]: Valid PID
	file (younger than sys uptime 0 0:33:00)
	2013-11-30T11:53:34.350920-08:00 newmail amavis[7164]: starting.
	/usr/local/sbin/amavisd at newmail.jennielan.int
	amavisd-new-2.7.0-pre15 (20110412), Unicode aware,
	LC_CTYPE="en_US.UTF-8", LANG="POSIX"
	2013-11-30T11:53:34.351340-08:00 newmail amavis[7164]:
	perl=5.018001, user=, EUID: 65 (65);  group=, EGID: 132 132 (132
	132)
	2013-11-30T11:53:34.397555-08:00 newmail amavis[7164]: bind to
	/var/lib/amavis/amavisd.sock|unix, 127.0.0.1:10024/tcp
	2013-11-30T11:53:34.398330-08:00 newmail amavis[7164]: _WARN:
	Pid_file "/var/lib/amavis/amavisd.pid" already exists. 
	Overwriting!
	2013-11-30T11:53:34.404544-08:00 newmail amavis[7172]:
	Net::Server: Process Backgrounded
	2013-11-30T11:53:34.406822-08:00 newmail amavis[7172]:
	Net::Server: 2013/11/30-11:53:34 Amavis (type
	Net::Server::PreForkSimple) starting! pid(7172)
	2013-11-30T11:53:34.416070-08:00 newmail amavis[7172]:
	Net::Server: Binding to UNIX socket file
	"/var/lib/amavis/amavisd.sock"
	2013-11-30T11:53:34.417537-08:00 newmail amavis[7172]:
	Net::Server: Binding to TCP port 10024 on host 127.0.0.1 with
	IPv4
	2013-11-30T11:53:34.419223-08:00 newmail amavis[7172]:
	Net::Server: Group Not Defined.  Defaulting to EGID '132 132'
	2013-11-30T11:53:34.420142-08:00 newmail amavis[7172]:
	Net::Server: User Not Defined.  Defaulting to EUID '65'
	2013-11-30T11:53:34.420958-08:00 newmail amavis[7172]:
	Net::Server: Setting up serialization via flock
	2013-11-30T11:53:34.423275-08:00 newmail amavis[7172]:
	after_chroot_init: EUID: 65 (65);  EGID: 132 132 (132 132)
	2013-11-30T11:53:34.424018-08:00 newmail amavis[7172]: config
	files read: /usr/local/etc/amavis/amavisd.conf
	2013-11-30T11:53:34.425656-08:00 newmail amavis[7172]:
	Net::Server: 2013/11/30-11:53:34 Server closing!

Even though it's supposedly a perl-daemon 'like' smtpprox, there's
apparently something different here.

Since amavisd launches without systemd just fine, I guess it's something
needed in systemd?

JenL


More information about the systemd-devel mailing list