On 01/10/2012 11:51 PM, Lennart Poettering wrote:
Yes. Most likely you don't even have to create the file
/etc/systemd/system/[email protected] at all, instead just symlink
it from /lib/systemd/system/[email protected], i.e. the common template.

Dan to give you an example which I used test to run multiple instances of vsftpd of an template unit a while back with quick and dirty directions I had noted down while doing it...

First here is a httpd template unit file for you to start fiddling with and tailor to your needs since this is rather lengthy post but should give you the general idea of what needs to be done and what Lennart is referring to....

### Sample [email protected] template ###

[Unit]
Description=The Apache HTTP Server Instance %i
After=network.target

[Service]
Type=forking
PIDFile=/run/httpd/%i.pid
ExecStart=/usr/sbin/httpd -f /etc/httpd/conf.d/%i.conf -k start
ExecReload=/usr/sbin/httpd -t
ExecReload=/bin/kill -HUP $MAINPID
ExecStop=/usr/sbin/httpd -k stop

[Install]
WantedBy=multi-user.target

The VSFTPD template unit.

### [email protected] ###

[Unit]
Description=Vsftpd FTP Daemon Server Instance %i
After=network.target

[Service]
Type=forking
ExecStart=/usr/sbin/vsftpd /etc/vsftpd/%i.conf

[Install]
WantedBy=multi-user.target

Next create a multiple copy's of the vsftpd.conf file

for i in 1 2 3 4;do cp /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd$i.conf; done

Set different log file for each of them...

for i in 1 2 3 4;do echo "xferlog_file=/var/log/vsftpd$i.log" >> /etc/vsftpd/vsftpd$i.conf; done

Set different listening port in each configuration file on them...

for i in 1 2 3 4;do echo "listen_port=200$i" >> /etc/vsftpd/vsftpd$i.conf; done

Then symbolic link that template to the name of the each configuration file

ln -s /lib/systemd/system/vsftpd\@.service /etc/systemd/system/vsftpd\@vsftpd1.service ln -s /lib/systemd/system/vsftpd\@.service /etc/systemd/system/vsftpd\@vsftpd2.service ln -s /lib/systemd/system/vsftpd\@.service /etc/systemd/system/vsftpd\@vsftpd3.service ln -s /lib/systemd/system/vsftpd\@.service /etc/systemd/system/vsftpd\@vsftpd4.service

Reload the systemd daemon

systemctl daemon-reload

Start each instance

systemctl start [email protected] [email protected] [email protected] [email protected]

Check to see if each instance is running and listening on different ports...

[root@localhost system]# systemctl status [email protected] [email protected] [email protected] [email protected]
[email protected] - Vsftpd FTP Daemon Server Instance vsftpd1
Loaded: loaded (/lib/systemd/system/[email protected]; enabled)
Active: active (running) since Wed, 11 Jan 2012 01:22:46 +0000; 2s ago
Process: 7351 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/%i.conf (code=exited, status=0/SUCCESS)
Main PID: 7358 (vsftpd)
CGroup: name=systemd:/system/[email protected]/vsftpd1
└ 7358 /usr/sbin/vsftpd /etc/vsftpd/vsftpd1.conf

[email protected] - Vsftpd FTP Daemon Server Instance vsftpd2
Loaded: loaded (/lib/systemd/system/[email protected]; enabled)
Active: active (running) since Wed, 11 Jan 2012 01:22:46 +0000; 2s ago
Process: 7352 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/%i.conf (code=exited, status=0/SUCCESS)
Main PID: 7357 (vsftpd)
CGroup: name=systemd:/system/[email protected]/vsftpd2
└ 7357 /usr/sbin/vsftpd /etc/vsftpd/vsftpd2.conf

[email protected] - Vsftpd FTP Daemon Server Instance vsftpd3
Loaded: loaded (/lib/systemd/system/[email protected]; enabled)
Active: active (running) since Wed, 11 Jan 2012 01:22:46 +0000; 2s ago
Process: 7353 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/%i.conf (code=exited, status=0/SUCCESS)
Main PID: 7355 (vsftpd)
CGroup: name=systemd:/system/[email protected]/vsftpd3
└ 7355 /usr/sbin/vsftpd /etc/vsftpd/vsftpd3.conf

[email protected] - Vsftpd FTP Daemon Server Instance vsftpd4
Loaded: loaded (/lib/systemd/system/[email protected]; enabled)
Active: active (running) since Wed, 11 Jan 2012 01:22:46 +0000; 2s ago
Process: 7354 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/%i.conf (code=exited, status=0/SUCCESS)
Main PID: 7356 (vsftpd)
CGroup: name=systemd:/system/[email protected]/vsftpd4
└ 7356 /usr/sbin/vsftpd /etc/vsftpd/vsftpd4.conf

[root@localhost system]# netstat -pant | grep vsftpd
tcp 0 0 :::2001 :::* LISTEN 7358/vsftpd
tcp 0 0 :::2002 :::* LISTEN 7357/vsftpd
tcp 0 0 :::2003 :::* LISTEN 7355/vsftpd
tcp 0 0 :::2004 :::* LISTEN 7356/vsftpd
_______________________________________________
systemd-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to