Am 06.03.2011 02:25, schrieb Jake Moe: > On 03/06/11 09:31, Florian Philipp wrote: >> Am 05.03.2011 23:47, schrieb Jake Moe: >>> I'm currently trying to write a simple initscript to run >>> minecraft-server on one of my boxes. I've looked at the ebuild provided >>> via java-overlay, but it turns out it uses baselayout 2, and I'm not >>> ready to go down that upgrade path on this particular box just yet. >>> >>> So far, I've managed to get a simple start() function written, which >>> kinda-sorta "works"; it will start the server, but there are two problems: >>> >>> 1) The "server" was written to stay interactive on a console, so you can >>> manage it from there. As such, the process never exits, so the >>> initscript gets stuck on "starting" >>> 2) There is nowhere in the server config file to specify where it writes >>> it's data files. So when I run this from my initscript, it seems to >>> default to the root directory, and I can't figure out how to tell it to >>> use something else as a working directory. >>> >>> So far, I've got this: >>> >>> depend() { >>> need bootmisc localmount net >>> } >>> >>> start() { >>> einfo "Starting Minecraft Server" >>> cd /usr/local/games/minecraft-server >>> start-stop-daemon --start --make-pidfile --pidfile >>> /var/run/minecraft-server.pid \ >>> --exec /usr/bin/java -- -Xmx1024M -Xms1024M -jar >>> /usr/local/games/minecraft-server/minecraft_server.jar nogui >>> eend $? >>> } >>> >>> Do any of the experts here know a way out of my dilemma? >>> >>> Jake Moe >>> >> >> You already know start-stop-daemon, good. Parameter --background will >> force the program to detach. That solves your first problem. >> >> --chdir should solve your second problem. You should also consider >> --user and --group to drop root privileges. It also sets $HOME in case >> the server does not write to the working directory but the home directory. >> >> Hope this helps, >> Florian Philipp >> > I've tried "--background", but then it just fails. Adding "--verbose" > as well gives the following: > > jmoe@aus8617 /etc/init.d $ sudo /etc/init.d/minecraft-server start > * Starting Minecraft Server > Starting /usr/bin/java... > Detaching to start /usr/bin/java...done. [ !! ] > > Not the most helpful of messages. >
Hmm, no clue what goes wrong. Joost already suggested it has something to do with stdout and stderr. You can redirect them with -1 and -2 but I don't think this solves your problem. Maybe you should take a look at dev-java/java-service-wrapper. I've never used it, though. > For the second, of what is "--chdir" an argument? If I read the man > page for start-stop-daemon, it had "--chroot" and "--chuid", but no > "--chdir". I assume that "--chuid" can be used for changing the > user:group of the resulting process, but did you mean chroot instead of > chdir, or does that go with another command? > In my man-page there is definitely a --chdir option. But I'm using openrc so I guess it was introduced in baselayout-2. As a work-around, you can wrap your daemon into a shell script that at first uses cd to change the directory. > Also, when I say "the root directory", I don't mean root's home > directory (/root), I mean the root (/) directory. So I wind up with > config files in the root of my filesystem. Not good. > Well in that case it really seems to be the working directory, not the home directory.
signature.asc
Description: OpenPGP digital signature