Permalink
Browse files

Merge pull request #1 from wuputah/master

Pull the Awesome Stuff from @wuputah
  • Loading branch information...
jacobwgillespie committed Aug 5, 2012
2 parents 7201cc6 + a0e97c3 commit 68ffdb2d3607cee89c0e91fadf8d4665e965a803
Showing with 33 additions and 16 deletions.
  1. +1 −1 Procfile
  2. BIN bin/minecraft_server.jar
  3. +3 −3 bin/poor-mans-cron.sh
  4. +24 −7 bin/run_minecraft.sh
  5. +3 −3 bin/setup_rsync.sh
  6. +1 −1 bin/sync-from-s3.sh
  7. +1 −1 bin/sync-to-s3.sh
View
@@ -1 +1 @@
-web: sh /app/bin/run_minecraft.sh
+server: /app/bin/run_minecraft.sh
View
Binary file not shown.
View
6 bin/poor-mans-cron.sh 100644 → 100755
@@ -2,8 +2,8 @@
if [ -z "$(pidof poor-mans-cron.sh)"]; then
while :
do
- sh /app/bin/sync-to-s3.sh
- sh /app/bin/sync-to-s3.sh
+ nice /app/bin/sync-to-s3.sh
+ nice /app/bin/sync-to-s3.sh
sleep 60
done
-fi
+fi
View
31 bin/run_minecraft.sh 100644 → 100755
@@ -1,10 +1,27 @@
#!/bin/bash
+
+function clean_shutdown {
+ kill $cron_pid
+ . /app/bin/sync-from-s3.sh
+}
+trap clean_shutdown SIGTERM
+
+# sync initial files
. /app/bin/sync-from-s3.sh
-echo "`cat /app/server.properties1`\nserver-port=$PORT\n`cat /app/server.properties2`" > /app/server.properties
+
+# setup background syncing
+nice /app/bin/poor-mans-cron.sh &
+cron_pid=$!
+
+# create server config
+cp /app/server.properties1 /app/server.properties
+echo "server-port=$PORT" >> /app/server.properties
+cat /app/server.properties2 >> /app/server.properties
+
+# print logs to stdout
+touch /app/server.log
+nice tail -f /app/server.log &
+
+# run minecraft
cd /app
-chmod +x /app/bin/poor-mans-cron.sh
-/app/bin/poor-mans-cron.sh &
-echo $! > cron.pid
-java -Xmx512M -Xms512M -jar /app/bin/minecraft_server.jar nogui
-kill `cat cron.pid`
-. /app/bin/sync-to-s3.sh
+java -Xmx1024M -Xms1024M -jar /app/bin/minecraft_server.jar nogui
View
6 bin/setup_rsync.sh 100644 → 100755
@@ -1,5 +1,5 @@
-#!/bin/sh
-curl -O https://raw.github.com/pypa/virtualenv/master/virtualenv.py
+#!/bin/bash
+curl -s https://raw.github.com/pypa/virtualenv/master/virtualenv.py > virtualenv.py
python virtualenv.py my_new_env
. my_new_env/bin/activate
-pip install boto_rsync
+pip install boto_rsync
View
2 bin/sync-from-s3.sh 100644 → 100755
@@ -4,4 +4,4 @@ if [ ! -d /app/my_new_env ]; then
else
. /app/my_new_env/bin/activate
fi
-boto-rsync -a $AWS_KEY -s $AWS_SECRET s3://$S3_BUCKET/ /app
+boto-rsync -a $AWS_KEY -s $AWS_SECRET s3://$S3_BUCKET/world /app/world
View
2 bin/sync-to-s3.sh 100644 → 100755
@@ -4,4 +4,4 @@ if [ ! -d /app/my_new_env ]; then
else
. /app/my_new_env/bin/activate
fi
-boto-rsync -a $AWS_KEY -s $AWS_SECRET /app s3://$S3_BUCKET/
+boto-rsync -a $AWS_KEY -s $AWS_SECRET /app/world s3://$S3_BUCKET/world

0 comments on commit 68ffdb2

Please sign in to comment.