From a3f6fdf3d0807e0fab8dce925563c78785838cc7 Mon Sep 17 00:00:00 2001 From: Wil Gieseler Date: Sun, 9 Feb 2014 13:12:17 -0800 Subject: [PATCH 01/13] try that no-ip --- minecloud/launcher/tasks.py | 11 +++++++++++ templates/launcher/index.html | 14 +++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/minecloud/launcher/tasks.py b/minecloud/launcher/tasks.py index cbed400..893cece 100644 --- a/minecloud/launcher/tasks.py +++ b/minecloud/launcher/tasks.py @@ -12,6 +12,8 @@ from .models import Instance from .sseview import send_event +import urllib2 + @task def launch(instance_id): # Retrive instance obj from DB. @@ -64,6 +66,15 @@ def launch(instance_id): instance.save() send_event('instance_state', instance.state) + # Update dynamic IP + dynamic_ip_hostname = os.getenv('NO_IP_HOSTNAME', None) + dynamic_ip_username = os.getenv('NO_IP_USERNAME', None) + dynamic_ip_password = os.getenv('NO_IP_PASSWORD', None) + if dynamic_ip_hostname and dynamic_ip_username and dynamic_ip_password: + opener = urllib2.build_opener() + opener.addheaders = [('User-agent', 'Minecloud-No-IP/1.0 http://github.com/toffer/minecloud')] + response = opener.open("http://" + urllib2.urlencode(dynamic_ip_username) + ":" + urllib2.urlencode(dynamic_ip_password) + "@dynupdate.no-ip.com/nic/update?hostname=" + urllib2.urlencode(dynamic_ip_hostname) + "&myip=" + urllib2.urlencode(server.ip_address)) + # Send task to check if instance is running check_state.delay(instance_id, 'running') diff --git a/templates/launcher/index.html b/templates/launcher/index.html index 001b4ff..6d23da4 100644 --- a/templates/launcher/index.html +++ b/templates/launcher/index.html @@ -41,6 +41,12 @@

Server Info

IP Address {{ instance.ip_address }} + {% if os.getenv('NO_IP_HOSTNAME', None) %} + + Hostname + {{ os.getenv('NO_IP_HOSTNAME', None) }} + + {% endif %} Start Time {{ instance.start }} @@ -74,6 +80,12 @@

Server Info

IP Address {{ instance.ip_address }} + {% if os.getenv('NO_IP_HOSTNAME', None) %} + + Hostname + {{ os.getenv('NO_IP_HOSTNAME', None) }} + + {% endif %} Start Time {{ instance.start }} @@ -177,6 +189,6 @@

Server is sleeping.

location.reload(true) }, false); - }); + }); {% endblock content %} \ No newline at end of file From a9963d11c3a039c7ada465163383d08e77560284 Mon Sep 17 00:00:00 2001 From: Wil Gieseler Date: Sun, 9 Feb 2014 13:30:46 -0800 Subject: [PATCH 02/13] oh right django --- minecloud/launcher/views.py | 1 + templates/launcher/index.html | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/minecloud/launcher/views.py b/minecloud/launcher/views.py index 3560070..26803d2 100644 --- a/minecloud/launcher/views.py +++ b/minecloud/launcher/views.py @@ -13,6 +13,7 @@ @login_required def index(request): + no_ip_hostname = os.getenv('NO_IP_HOSTNAME', None) instance = None current_sessions = None err_msg = None diff --git a/templates/launcher/index.html b/templates/launcher/index.html index 6d23da4..3f9c2d1 100644 --- a/templates/launcher/index.html +++ b/templates/launcher/index.html @@ -41,10 +41,10 @@

Server Info

IP Address {{ instance.ip_address }} - {% if os.getenv('NO_IP_HOSTNAME', None) %} + {% if no_ip_hostname %} Hostname - {{ os.getenv('NO_IP_HOSTNAME', None) }} + {{ no_ip_hostname }} {% endif %} @@ -80,10 +80,10 @@

Server Info

IP Address {{ instance.ip_address }} - {% if os.getenv('NO_IP_HOSTNAME', None) %} + {% if no_ip_hostname %} Hostname - {{ os.getenv('NO_IP_HOSTNAME', None) }} + {{ no_ip_hostname }} {% endif %} From 99afdbedfdd286b50e169f15871b42a6063da936 Mon Sep 17 00:00:00 2001 From: Wil Gieseler Date: Sun, 9 Feb 2014 13:32:10 -0800 Subject: [PATCH 03/13] import os --- minecloud/launcher/views.py | 1 + 1 file changed, 1 insertion(+) diff --git a/minecloud/launcher/views.py b/minecloud/launcher/views.py index 26803d2..4c9e86e 100644 --- a/minecloud/launcher/views.py +++ b/minecloud/launcher/views.py @@ -10,6 +10,7 @@ from .models import Instance, Session from .sseview import SseView, send_event +import os @login_required def index(request): From fbabbe82dc4be51e6304d5638e5eb90c3f973621 Mon Sep 17 00:00:00 2001 From: Wil Gieseler Date: Sun, 9 Feb 2014 13:44:58 -0800 Subject: [PATCH 04/13] correctly send that get request --- minecloud/launcher/tasks.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/minecloud/launcher/tasks.py b/minecloud/launcher/tasks.py index 893cece..b16e740 100644 --- a/minecloud/launcher/tasks.py +++ b/minecloud/launcher/tasks.py @@ -12,7 +12,10 @@ from .models import Instance from .sseview import send_event +import urllib import urllib2 +import base64 +import string @task def launch(instance_id): @@ -72,8 +75,10 @@ def launch(instance_id): dynamic_ip_password = os.getenv('NO_IP_PASSWORD', None) if dynamic_ip_hostname and dynamic_ip_username and dynamic_ip_password: opener = urllib2.build_opener() - opener.addheaders = [('User-agent', 'Minecloud-No-IP/1.0 http://github.com/toffer/minecloud')] - response = opener.open("http://" + urllib2.urlencode(dynamic_ip_username) + ":" + urllib2.urlencode(dynamic_ip_password) + "@dynupdate.no-ip.com/nic/update?hostname=" + urllib2.urlencode(dynamic_ip_hostname) + "&myip=" + urllib2.urlencode(server.ip_address)) + auth = base64.encodestring('%s:%s' % (dynamic_ip_username, dynamic_ip_password)).replace('\n', '') + opener.addheaders = [('User-agent', 'Minecloud-No-IP/1.0 http://github.com/toffer/minecloud'), ("Authorization", "Basic %s" % auth)] + url = "http://dynupdate.no-ip.com/nic/update?hostname=" + urllib.quote_plus(dynamic_ip_hostname) + "&myip=" + urllib.quote_plus(server.ip_address) + opener.open(url) # Send task to check if instance is running check_state.delay(instance_id, 'running') From d95e5affbb1cfed282c71852f27b62d8d962fccf Mon Sep 17 00:00:00 2001 From: Wil Gieseler Date: Sun, 9 Feb 2014 13:51:12 -0800 Subject: [PATCH 05/13] correctly pass hostname to view --- minecloud/launcher/views.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/minecloud/launcher/views.py b/minecloud/launcher/views.py index 4c9e86e..4032447 100644 --- a/minecloud/launcher/views.py +++ b/minecloud/launcher/views.py @@ -14,12 +14,11 @@ @login_required def index(request): - no_ip_hostname = os.getenv('NO_IP_HOSTNAME', None) instance = None current_sessions = None err_msg = None running_instances = Instance.objects.exclude(state__exact='terminated') - if len(running_instances) == 1: + if len(running_instances) == 1: instance = running_instances[0] current_sessions = (Session.objects .filter(instance_id__exact=instance.id) @@ -27,12 +26,13 @@ def index(request): ) elif len(running_instances) > 1: err_msg = "Error: Multiple instances are running at once." - return render(request, + return render(request, 'launcher/index.html', {'instance': instance, 'sessions': current_sessions, + 'no_ip_hostname': os.getenv('NO_IP_HOSTNAME', None), 'err_msg': err_msg}) - + @login_required @require_POST def launch(request): From 75482d56e532f0e922ccaffa4e5fe2e5bd0c58b5 Mon Sep 17 00:00:00 2001 From: Wil Gieseler Date: Sun, 9 Feb 2014 13:59:48 -0800 Subject: [PATCH 06/13] display the hostname prominently if available --- templates/launcher/index.html | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/templates/launcher/index.html b/templates/launcher/index.html index 3f9c2d1..65c0d3f 100644 --- a/templates/launcher/index.html +++ b/templates/launcher/index.html @@ -30,7 +30,14 @@

Server Info

{% elif instance and instance.state == 'pending' %}
-

Server is waking up at {{ instance.ip_address }}.

+

Server is waking up at + + {% if no_ip_hostname %} + {{ no_ip_hostname }} + {% else %} + {{ instance.ip_address }} + {% endif %} + .

Now, it's restoring saved game data. Almost ready...

@@ -62,7 +69,15 @@

Server Info

{% elif instance and instance.state == 'running' %}
-

Server is running at {{ instance.ip_address }}.

+

Server is running at + + {% if no_ip_hostname %} + {{ no_ip_hostname }} + {% else %} + {{ instance.ip_address }} + {% endif %} + . +

From e63be498f1330a0e892293bfbdb06cee3ac2244b Mon Sep 17 00:00:00 2001 From: Wil Gieseler Date: Sun, 9 Feb 2014 14:02:51 -0800 Subject: [PATCH 07/13] explanatory text changes if you have a hostname --- templates/launcher/index.html | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/templates/launcher/index.html b/templates/launcher/index.html index 65c0d3f..991759f 100644 --- a/templates/launcher/index.html +++ b/templates/launcher/index.html @@ -37,7 +37,8 @@

Server is waking up at {% else %} {{ instance.ip_address }} {% endif %} - .

+ +

Now, it's restoring saved game data. Almost ready...

@@ -50,7 +51,7 @@

Server Info

{% if no_ip_hostname %} - Hostname + DDNS Hostname {{ no_ip_hostname }} {% endif %} @@ -76,15 +77,21 @@

Server is running at {% else %} {{ instance.ip_address }} {% endif %} - . +

Join the server!

    + {% if no_ip_hostname %} +
  • Open Minecraft, click Multiplayer, and add a new server.
  • +
  • Copy above hostname into the Server Address field.
  • + {% else %}
  • Open Minecraft, click Multiplayer, and edit the Server Info.
  • Copy the IP address into the Server Address field.
  • +
  • This IP address will change each time the server is restarted.
  • + {% endif %}
@@ -97,7 +104,7 @@

Server Info

{% if no_ip_hostname %} - Hostname + DDNS Hostname {{ no_ip_hostname }} {% endif %} From ee0962ccad4cf1a23206928e0416b83c017015e1 Mon Sep 17 00:00:00 2001 From: Wil Gieseler Date: Sun, 9 Feb 2014 14:09:41 -0800 Subject: [PATCH 08/13] Add DDNS config vars to readme --- README.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.rst b/README.rst index efa3f69..570c596 100644 --- a/README.rst +++ b/README.rst @@ -109,6 +109,14 @@ Steps to get up-and-running on Heroku: # to set the MCL_EC2_REGION variable $ heroku config:set MCL_EC2_REGION= + # Optional Dynamic DNS Settings + # If you don't want to have a constantly-changing IP address, you can add your + # login credentials for https://www.noip.com (a free service that will give you) + # a URL that Minecloud will automatically point to your server IP. + $ heroku config:set NO_IP_HOSTNAME=my-great-hostname.servegame.com + $ heroku config:set NO_IP_USERNAME=me@example.com + $ heroku config:set NO_IP_PASSWORD=secretpassword + # Review all your settings $ heroku config From 1ce216f084dd58d16d192e50768987730ec55ca5 Mon Sep 17 00:00:00 2001 From: Wil Gieseler Date: Sun, 9 Feb 2014 14:10:52 -0800 Subject: [PATCH 09/13] Fix language in readme --- README.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 570c596..371e5fe 100644 --- a/README.rst +++ b/README.rst @@ -111,8 +111,10 @@ Steps to get up-and-running on Heroku: # Optional Dynamic DNS Settings # If you don't want to have a constantly-changing IP address, you can add your - # login credentials for https://www.noip.com (a free service that will give you) - # a URL that Minecloud will automatically point to your server IP. + # login credentials for https://www.noip.com (which is free!) + # + # This service gives you a URL that Minecloud will automatically point + # to your server IP and keep up to date. $ heroku config:set NO_IP_HOSTNAME=my-great-hostname.servegame.com $ heroku config:set NO_IP_USERNAME=me@example.com $ heroku config:set NO_IP_PASSWORD=secretpassword From 82f9633a03efe92b31bdebb4bdffe11f46ad9be8 Mon Sep 17 00:00:00 2001 From: Jeff Date: Tue, 2 Dec 2014 18:32:04 +0100 Subject: [PATCH 10/13] Remove distribute from requirements --- requirements.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/requirements.txt b/requirements.txt index 8266f56..f82cf5b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,7 +7,6 @@ billiard==2.7.3.19 boto==2.6.0 celery==3.0.12 celerymon==1.0.3 -distribute==0.6.24 dj-database-url==0.2.1 django-celery==3.0.11 django-heroku-memcacheify==0.4 @@ -21,7 +20,7 @@ greenlet==0.4.0 gunicorn==0.16.1 honcho==0.2.0 kombu==2.5.3 -newrelic==1.10.2.38 +newrelic>=2.38.2.33 paramiko==1.9.0 psycopg2==2.4.5 pycrypto==2.6 @@ -30,4 +29,3 @@ python-dateutil==1.5 pytz==2012h redis==2.7.2 sse==1.2 -wsgiref==0.1.2 From 7fc0f7d7d7509e5528ea8d0743d8b9dac408d85e Mon Sep 17 00:00:00 2001 From: Jeff Date: Wed, 3 Dec 2014 00:28:32 +0100 Subject: [PATCH 11/13] remove versions for gevent --- requirements.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/requirements.txt b/requirements.txt index f82cf5b..18b1bf6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,9 +15,9 @@ django-pylibmc-sasl==0.2.4 django-registration==0.8 django-secure==0.1.2 django-sse==0.4.1 -gevent==0.13.8 -greenlet==0.4.0 -gunicorn==0.16.1 +gevent +greenlet +gunicorn honcho==0.2.0 kombu==2.5.3 newrelic>=2.38.2.33 From 442a9ea2e409d52492fd16a2802d73953444952c Mon Sep 17 00:00:00 2001 From: Jeff Date: Wed, 3 Dec 2014 15:38:26 +0100 Subject: [PATCH 12/13] Update requirements.txt, remove distribute and wsgiref --- requirements.txt | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/requirements.txt b/requirements.txt index 8266f56..18b1bf6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,7 +7,6 @@ billiard==2.7.3.19 boto==2.6.0 celery==3.0.12 celerymon==1.0.3 -distribute==0.6.24 dj-database-url==0.2.1 django-celery==3.0.11 django-heroku-memcacheify==0.4 @@ -16,12 +15,12 @@ django-pylibmc-sasl==0.2.4 django-registration==0.8 django-secure==0.1.2 django-sse==0.4.1 -gevent==0.13.8 -greenlet==0.4.0 -gunicorn==0.16.1 +gevent +greenlet +gunicorn honcho==0.2.0 kombu==2.5.3 -newrelic==1.10.2.38 +newrelic>=2.38.2.33 paramiko==1.9.0 psycopg2==2.4.5 pycrypto==2.6 @@ -30,4 +29,3 @@ python-dateutil==1.5 pytz==2012h redis==2.7.2 sse==1.2 -wsgiref==0.1.2 From f484aa66b9a5365b230be77ae8ebad589e367a6e Mon Sep 17 00:00:00 2001 From: Jeff Date: Thu, 4 Dec 2014 01:58:26 +0100 Subject: [PATCH 13/13] switch to medium --- minecloud/launcher/tasks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/minecloud/launcher/tasks.py b/minecloud/launcher/tasks.py index b16e740..88c37c5 100644 --- a/minecloud/launcher/tasks.py +++ b/minecloud/launcher/tasks.py @@ -26,7 +26,7 @@ def launch(instance_id): ec2_ami = os.getenv('MCL_EC2_AMI') ec2_region = os.getenv('MCL_EC2_REGION', 'us-west-2') ec2_keypair = os.getenv('MCL_EC2_KEYPAIR','MinecraftEC2') - ec2_instancetype = os.getenv('MCL_EC2_INSTANCE_TYPE', 'm1.small') + ec2_instancetype = os.getenv('MCL_EC2_INSTANCE_TYPE', 'm3.medium') ec2_secgroups = [os.getenv('MCL_EC2_SECURITY_GROUP', 'minecraft')] # ec2_env_vars populate the userdata.txt file. Cloud-init will append