Shell Startup mangosd via screen & daemon by /usr/local/etc/rc.d

Hello everyone!

It`s my first expirience by adding rc.d scripts in system. I want my system start 2 application (realmd and mangosd) after restart\rebooting server, as i see it for one of this app:

1. rc.d script start screen session
screen -S mangosdscreensession
2. in this screen session it`s give command to start daemon(8) :
daemon -r /opt/mangos/bin/mangosd -c /etc/mangosd.conf


Why daemon? As i know it can restart process\if it crash - thats what i need too ;)

I maked 2 script, mangosd and realmd.

Code:
#!/bin/sh
# REQUIRE: DAEMON

realmd_enable=${realmd_enable-"NO"}

. /etc/rc.subr

name="realmd"
rcvar=realmd_enable
#pidfile="${realmd_pidfile}"

command="/opt/mangos/bin/realmd"
command_interpreter="/usr/local/bin/python2.7"

load_rc_config ${name}

start_cmd="/opt/mangos/bin/realmd -s run"
stop_cmd=" /opt/mangos/bin/realmd -s stop"

run_rc_command "$1"

And only this script work at half as i want ( i mean without daemon, and without screen session), and it only can start it, by service realmd start. When i tried stop it by command service realmd stop it give me this:
/usr/local/etc/rc.d/realmd: WARNING: no shebang line in /opt/mangos/bin/realmd
No pid file specified

With mangosd application , i cant even start it, it requiere as i understand started in "normal" mode, or in screen session, i tried many varriants starts it with "daemon" options but it want to work... and i even cant see logs.
Code:
    Running as daemon functions:
    -s run                   run as daemon
    -s stop                  stop daemon

But i idealy run this app (mangosd) by manualy, as i said before:
$ screen -S mangosdsessionname
in screen session:
$ daemon -r /opt/mangos/bin/mangosd -c /etc/mangosd.conf

so my question is how to implement this commands in "rc.d" script ?


thank you! And sorry for my english if it not perfect!
 
Why would they need to be started in a screen session? And the daemon(8) utility doesn't stop or restart anything, it simply detaches a process from the terminal. Essentially disconnecting it from screen(1) or any other terminal.

If you want something that can automatically start and restart (after a crash for example) a process you're probably better off using something like sysutils/daemontools. It's a really old tool but still extremely useful.
 
Back
Top