Page creation
Done with my first draft... Comments, modification, experiences, help? Cheers Sakamura 20:50, 26 February 2011 (UTC)
- Just got done setting up this up on a Mini Server running OS X Server and here's a few things I learned. I think it might help make this guide a little clearer to just remove all the references to the "easy ways" to do things. My Java process does stop properly but the tail hangs around (naturally) so my script kills the tail command after Java exits. I want to be able to run a second server in the future so my scripts include a "server name". I don't know if anyone else wants to do that, but here's my setup in case:
#!/bin/bash
server_name=server_ross
cd /Users/_minecraft/${server_name}
trap '{ echo "$(date) Killing Minecraft, ${server_name}."; ./stop.sh; exit 0; }' TERM INT
ipconfig waitall
echo "$(date) Starting Minecraft, ${server_name}."
./start.sh &
wait
echo "$(date) Minecraft, ${server_name} done."- Here's my start.sh. The pipe file has been renamed to include the server name so stop.sh can find the tail process to kill it. The -Dnet.minecraft.server=${server_name} is also just there for finding the right server when stopping.
#!/bin/bash
server_name=server_ross
cd /Users/_minecraft/${server_name}
rm command_pipe.${server_name}
touch command_pipe.${server_name}
tail -f command_pipe.${server_name} | java -Xmx1G -Xms1G -Dnet.minecraft.server=${server_name} -jar minecraft_server.jar nogui- Finally, my stop.sh script which also kills the tail process.
#!/bin/bash
server_name=server_ross
cd /Users/_minecraft/${server_name}
echo stop >> command_pipe.${server_name}
while ps -u _minecraft | grep "net.minecraft.server=${server_name}" | grep -qv grep
do
sleep 1
done
# We have to kill the tail that was feeding Java.
tailpid=$(ps -u _minecraft | grep command_pipe.${server_name} | grep -v grep | cut -c 6-11)
kill $tailpid- Rossiam 01:00, 3 May 2011 (UTC)
On-demand start & stop daemon
Hello,
I think you did a fantastic job here, considering that I have now my own minecraft server properly configured to start with my Mac whereas I am not really accustomed to the Mac command line (yes, I must admit I'm mostly a PC user).
I still have a few questions about this tutorial (please pardon my noobfullness) :
- Is it possible to adapt your daemon to launch on demand, i.e. when the first client asks for server connection (by listening to port 25565 connection attempts maybe ?)
- ... and to stop when the last client disconnects, i.e. when nobody's using the server
- and maybe also to launch updates automatically (I've seen some linux scripts available online1 that can do that among other thinks, but I have no idea how to adapt them).
Also, I had to use portmap2 to force port forwarding on my router (did not work without it). Is there a way to start portmap daemon along with the server ?
Thank you again for sharing your Mac OS X startup daemon with the community.
1, like here : planetminecraft.com/blog/automatically-stop-a-server-when-nobodys-playing
2, www.codingmonkeys.de/portmap/
--Oulipion (talk) 00:16, 7 October 2013 (UTC)