Jump to content
  • 0

Freebsd: daemonize realmd and mangosd


amaroc

Question

Hello guys! I ve installed this beutifull server, and want keep it work all time on my server. I am not pro in freebsd, but tried to solve this problem.

As i know exist "daemon(8)" wich one can start, and restart application if it terminated. It`s sound more fine and good then just start server manualy in screen and deatch by clossing ssh connection. 

But i tried many ways, and it dont want to run it in backgroun mode by this script and by manualy (in background).

 

Firstable let me link my /etc/rc.d/realmd script:
 

#!/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"

looks like it works perfectly in background by command "service realmd start". I start it, clossed session ssh and all works fine. One moment dont work service realmd stop i get it in output:

 #service realmd stop
/usr/local/etc/rc.d/realmd: WARNING: no shebang line in /opt/mangos/bin/realmd
No pid file specified


- but it not so scary, when i want to kill it i can find it manualy with ps() and grep().

But same script with same sintaxys, and commands want start mangosd in background, i  tried 30-40 variants, and with "screen" and with "daemon -f" and with "daemon -rf", nothing can start mangosd in backgroun ;( And yes i tried run it with this script like  

# /opt/mangos/bin/mangosd -c /etc/mangosd.conf -s run
- but it still dont want work properly ;(

# /opt/mangos/bin/mangosd -s run
- same thing. nothing, no life process

And ofcorse its perfectly start without -s run.

So if u have expirience in FreeBSD, maybe you can help me, i believe many newbie WoW admins looking for this info, if they used FreeBSD.

 

At this moment i run mangosd manualy in screen with daemon ;P

screen -S mangosd

daemon -r /opt/mangos/bin/mangosd

 

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

For your scripts to work properly, there are some constraints, namely

  1. In magosd.conf:
    • Use absolute paths instead of relative ones
    • Maandatory specify the location of pid file
    • Supress the console output (Console.Enable=0)
  2. In your service scripts:
    • specify mysql as the anchor service, not daemon, as mangosd/realmd need MySQL server up and running (i.e. #REQUIRE mysql)
    • specify the location of the config file in the command args, via -c

As an example, for my system (the server is located in /usr/local/wowcl)

#!/bin/sh

# REQUIRE: mysql

. /etc/rc.subr

name="mangosd"
mangosd_enable=${mangosd_enable-"NO"}
mangosd_config=${mangosd_config-"/usr/local/wowcl/etc/mangosd.conf"}

rcvar=mangosd_enable

command="/usr/local/wowcl/bin/mangosd -c${mangosd_config}"

load_rc_config ${name}

start_cmd="${command} -s run"
stop_cmd="${command} -s stop"

run_rc_command "$1"

Link to comment
Share on other sites

On 16.12.2016 at 1:44 PM, H0zen said:

For your scripts to work properly, there are some constraints, namely

  1. In magosd.conf:
    • Use absolute paths instead of relative ones
    • Maandatory specify the location of pid file
    • Supress the console output (Console.Enable=0)
  2. In your service scripts:
    • specify mysql as the anchor service, not daemon, as mangosd/realmd need MySQL server up and running (i.e. #REQUIRE mysql)
    • specify the location of the config file in the command args, via -c

 

Thank you H0zen for super answer, it`s realy help my make this script by your example and advices. 

But how start it in screen session with daemon(8)? Or it is imposible?

In this case i will have some advantage like:
- daemon will restart service mangosd\realmd if it crashes.

- i will have access to screen session and see what`s happened, and can access to console.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use