I've attempted to use the example given here for running a perl script as a daemon:
However, when attempting to start the daemon I'm getting the following error: systemd1: myDaemon.service: Can't open PID file /run/myDaemon.pid (yet?) after start: Operation not permitted
I've found several others who've had this issue, but none of the suggested fixes, such as changing the pid location from /var/run to /run, have worked for me. Any suggestions?
Here is the contents of /etc/init.d/myDaemon:
#!/bin/bash
#
# myDaemon This starts and stops myDaemon 
#
# chkconfig: 2345 12 88
# description: myDaemon is a perl script that does stuff
# processname: myDaemon
# pidfile: /run/myDaemon.pid
### BEGIN INIT INFO
# Provides: $myDaemon
### END INIT INFO
# Source function library.
. /lib/lsb/init-functions
binary="/home/myuser/myDaemon.pl"
[ -x $binary ] || exit 0
RETVAL=0
start() {
    echo -n "Starting myDaemon: "
    daemon $binary
    RETVAL=$?
    PID=$!
    echo
    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/myDaemon
    echo $PID > /run/myDaemon.pid
}
stop() {
    echo -n "Shutting down myDaemon: "
    killproc myDaemon
    RETVAL=$?
    echo
    if [ $RETVAL -eq 0 ]; then
        rm -f /var/lock/subsys/myDaemon
        rm -f /run/myDaemon.pid
    fi
}
restart() {
    echo -n "Restarting myDaemon: "
    stop
    sleep 2
    start
}
case "$1" in
    start)
        start
    ;;
    stop)
        stop
    ;;
    status)
        status myDaemon
    ;;
    restart)
        restart
    ;;
    *)
        echo "Usage: $0 {start|stop|status|restart}"
    ;;
esac
exit 0
And here are the relevant contents of the perl script under /home/myUser/myDaemon.pl:
    #! /usr/bin/perl
    use strict;
    use warnings;
    use Proc::Daemon;
    
    # Proc::Daemon
    Proc::Daemon::Init;
    my $continue = 1;
    $SIG{TERM} = sub { $continue = 0 };
while($continue) {
  # does stuff
}
