# rc.d script for perl service



## elm (Feb 27, 2015)

I'm trying to create a rc.d script for a Perl service. The perl script can restart it self. It does that by executing `exec $^X ...[1]`. The problem is that when it is first started it uses the shebang to execute Perl which results in a ps entry like `/usr/bin/perl /path/to/myScript.pl` but after the restart the ps entry is `/usr/local/bin/perl5 /path/to/myScript.pl`. That confuses the rc.subr() routines and it cannot detect the running program anymore.

The Perl script is able to provide a correct PID file at any time but the check_pidfile routine also checks the executable name which only works if command_interpeter is set to `/usr/bin/perl`.

Does anyone have any idea how to proceed from here?

[1] http://perldoc.perl.org/perlvar.html#$EXECUTABLE_NAME


----------



## drummondislebsd (Mar 1, 2015)

Not certain here...

But there is declaration in rc.conf indicating that changes in rc.conf are overwritten by declarations in rc.conf.local.  So, when you say, "upon restart..." the process (ps) result changes and script fails.  Maybe, you need to create entries into rc.conf.local to assure your script directives are not lost/reset by rc.conf upon restart.

And/or maybe create symbolic links between /usr/bin/perl and usr/local/bin/perl5.


----------



## wblock@ (Mar 1, 2015)

/usr/bin/perl is already created by the package or port.


----------



## junovitch@ (Mar 2, 2015)

Something to keep in mind is that the /usr/bin/perl symlink will be going away for lang/perl5.20.  Fixing things now to be future proof would be beneficial.

See below for the drop of the "USE_PERL" symlink option.
https://svnweb.freebsd.org/ports/head/lang/perl5.20/Makefile?r1=355464&r2=355497


----------

