From: Joost Roeleveld <joost@antarean.org>
To: gentoo-user@lists.gentoo.org
Subject: Re: [gentoo-user] Writing Gentoo initscript question
Date: Sun, 06 Mar 2011 07:48:05 +0100 [thread overview]
Message-ID: <20110306065238.CD24A2A2B@data.antarean.org> (raw)
In-Reply-To: <4D72E29B.2090909@gmail.com>
On Sunday 06 March 2011 11:25:47 Jake Moe wrote:
> 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.
>
> 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?
>
> 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.
>
> Jake Moe
Not sure if it's the "recommended" way, but how about using "nohup"?
Eg:
start-stop-daemon --start --make-pidfile --pidfile
/var/run/minecraft-server.pid \
--exec nohup /usr/bin/java -- -Xmx1024M -Xms1024M -jar
Might be that it fails because it looses the stdout/stderr?
--
Joost
next prev parent reply other threads:[~2011-03-06 6:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-05 22:47 [gentoo-user] Writing Gentoo initscript question Jake Moe
2011-03-05 23:31 ` Florian Philipp
2011-03-06 1:25 ` Jake Moe
2011-03-06 6:48 ` Joost Roeleveld [this message]
2011-03-06 7:37 ` Jake Moe
2011-03-06 10:57 ` Florian Philipp
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110306065238.CD24A2A2B@data.antarean.org \
--to=joost@antarean.org \
--cc=gentoo-user@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox