Jump to content

daemonizing Mangos?


Recommended Posts

Posted

Just a little question about running Mangos as a true daemon on a *nix machine.

After finally digging a little deeper around in the code, it looks to me that both realmd and mangosd could be convinced to run as well-behaved daemons. Leaving out the -DENABLE_CLI compile time flag would get it started, and some additions to detach from the console would do it-

Or so it looks to me. In fact, it looks like things are pretty much set to go, with only that cli not being configured in and the pid and log files needing to be in place to make it so.

Which brings me, finally, to my question: am I missing something and things +are+ ready to run as daemons and I'm merely thinking about reinventing the wheel, or does Mangos need serious tweaking to get along with init?

Posted
This is very interesting. Would be nice to have it running as a daemon then im guessing RA in?

RA and Cli-Console are bundled, if you disable console you are not able to use RA.

(this was my experince) Cause I do not use RA or Console I don't care.

Using mangos as a daemon since some years now without problems.

just need a good starting/restarting script. (search the forum, or just write one)

Posted

Ahh i see :)

I use this if anyone finds use for it :)

until /opt/mangos/bin/mangos-realmd -c /opt/mangos/etc/realmd.conf 2>&1;

do date && echo "Realm server died with exit code $?. Restarting...";

sleep 1;

done;

until /opt/mangos/bin/mangos-worldd -c /opt/mangos/etc/mangosd.conf 2>&1;

do date && echo "World server died with exit code $?. Restarting...";

sleep 1;

done;

Posted

He probably meant _real_ daemon, not just script handler. Well, I'd add that to the core once it's stable. Because a server, which is able to crash after few hours (days) without warning isn't a good candidate for daemon. Restarting such server would cause more pain than it's necessary.

Not to mention that you can actually write a small standalone prog to daemonize mangos.

Posted

Btw you can always run mangos as "daemon" using the screen. I start mangos with

$ screen -dmS mangos /path/to/mangos/bin/mangos-worldd

With this command mangos will start in named screen (wchich can be any time re-attached using screen -r mangos and deattached again) and it will behave as daemon. You can let mangos to create pid file and check it in restarter, or you can grep ps or use telnet to verify if its running.

Posted

freghar got it, and it's what I suspected.

I was curious enough to ask those that know the codebase first rather than bang my head against the suspected wall. A quick overview of the server portion of the code looked like most of the prerequisites were already in place, with only detaching from the console and perhaps some signal handlers added to make it a true daemon. It looks to me like that's all that's required, but I'll now leave doing that to the people that know the code intimately when they decide things are ready. I'd just break things, I think. :)

Thanks for the tips on shell scripts and screen. They're appreciated, but I'd already found them elsewhere in the forum (and discovered for myself that yes, running things NOHUP eats CPU like it's candy).

Posted
Btw you can always run mangos as "daemon" using the screen. I start mangos with

$ screen -dmS mangos /path/to/mangos/bin/mangos-worldd

With this command mangos will start in named screen (wchich can be any time re-attached using screen -r mangos and deattached again) and it will behave as daemon. You can let mangos to create pid file and check it in restarter, or you can grep ps or use telnet to verify if its running.

freghar got it, and it's what I suspected.

I was curious enough to ask those that know the codebase first rather than bang my head against the suspected wall. A quick overview of the server portion of the code looked like most of the prerequisites were already in place, with only detaching from the console and perhaps some signal handlers added to make it a true daemon. It looks to me like that's all that's required, but I'll now leave doing that to the people that know the code intimately when they decide things are ready. I'd just break things, I think. :)

Thanks for the tips on shell scripts and screen. They're appreciated, but I'd already found them elsewhere in the forum (and discovered for myself that yes, running things NOHUP eats CPU like it's candy).

If you want mangos as a _real_ daemon, nothing stands between you and such goal.

Use a simple C program for example - close all I/O FDs, reopen 0,1,2 (stdin,out,err) on /dev/null, fork() under init, change process group ID, load mangos-worldd into own memory space and execute it (using exec() / execv() / execve() / ...). It's that simple.

Python has that on ~6 lines.

Posted
If you want mangos as a _real_ daemon, nothing stands between you and such goal.

Use a simple C program for example - close all I/O FDs, reopen 0,1,2 (stdin,out,err) on /dev/null, fork() under init, change process group ID, load mangos-worldd into own memory space and execute it (using exec() / execv() / execve() / ...). It's that simple.

Python has that on ~6 lines.

Or if you wanna mangos as a real daemon really really fast you can add one simple line to mangos:

daemon(0,0);

See man 3 daemon for any other info ;)

×
×
  • 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