[Oops, I just noticed I forgot to send this to the list. Sorry for the dupe, Risto.]
On 9/17/2014 1:33 PM, Eric V. Smith wrote: > It just occurs to me that another way to do this is to have an > EnvironmentFile= configuration line (which specifies a filename that > contains environment variables, like /etc/sysconfig/sec), and maybe I > could specify the input files as -input=${INPUT_FILENAME_%I}. I'll have > to play with how systemd expands %-variables and environment variables. > Then I could in fact use the %I multiple instance mode, which would save > me some hassle on starting the services. I'll report back what I find. Okay, here's what I've come up with. The above approach will in fact work. Here's /etc/systemd/system/sec@.service. Note the '@' in the filename. Also note that ExecStart is all one line, I'm not really sure if systemd lets you split lines like I've shown here: ---------------------------------- [Unit] Description=Simple Event Correlator script to filter log file entries After=syslog.target [Service] Type=simple PIDFile=/run/sec-$I.pid EnvironmentFile=/etc/sysconfig/sec ExecStart=/usr/bin/sec --nodetach --pid=/run/sec-%I.pid \ ${INPUT_%I} --conf=/etc/sec/sec-%I.conf \ --log=/var/log/sec-%I -intevents [Install] WantedBy=multi-user.target ---------------------------------- And here's /etc/sysconfig/sec ---------------------------------- INPUT_1=--input=/var/log/messages --input=/var/log/maillog INPUT_2=--input=/var/log/secure ---------------------------------- With these 2 files in place, I can: systemctl start sec@1.service systemctl start sec@2.service Which gives me these truncated lines from ps: /usr/bin/perl -w /usr/bin/sec --nodetach --pid=/run/sec-1.pid --input=/var/log/messages --input=/var/log/ /usr/bin/perl -w /usr/bin/sec --nodetach --pid=/run/sec-2.pid --input=/var/log/secure --conf=/etc/sec/sec So now, without creating additional .service files, I can start multiple sec instances just by modifying each sec-N.conf file and putting the input files into /etc/sysconfig/sec. It works perfectly! I probably need to run "systemctl enable sec@1.service", etc., if I want the WantedBy line to be picked up. My framework happens to do that. I switched to --nodaemon and type=simple. I was having problems with --daemon and type=forking, but that may just have been an error in my experimental setup while I was playing around. Anyway, I'm leaving it at type=simple. Note that with this scheme I'm not using the sec.service file that comes with Fedora. I'll just mask sec.service, and there won't be a risk of it starting. Thanks for letting me bounce ideas off of you. Hopefully this helps someone in the future. -- Eric. ------------------------------------------------------------------------------ Slashdot TV. Video for Nerds. Stuff that Matters. http://pubads.g.doubleclick.net/gampad/clk?id=160591471&iu=/4140/ostg.clktrk _______________________________________________ Simple-evcorr-users mailing list Simple-evcorr-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users