Getting SmartFox Server working on Amazon EC2 (GUIDE)

Need help with SmartFoxServer? You didn't find an answer in our documentation? Please, post your questions here!

Moderators: Lapo, Bax

ironchef123
Posts: 4
Joined: 21 Dec 2009, 20:20

Getting SmartFox Server working on Amazon EC2 (GUIDE)

Postby ironchef123 » 22 Dec 2009, 05:50

Ok, so Amazon EC2 is very cool but getting it to work with Smartfox in Windows is NOT cool (see below). This is what you have to do to get it up and working. I hope no one else has to go through figuring this out because it is not fun. Maybe this will save someone else a headache. I am not sure what is up with the formatting but going through this was a soul draining experience and I dont at the moment feel like fixing it.

Credit to these two articles for providing much of the source material (thanks guys!):
http://www.powercram.com/2009/12/instal ... ls-on.html
http://overstimulate.com/articles/amazon-does-it-again

Set Up an EC2 Account: http://aws.amazon.com/ec2/

You will have to provide a credit card (you won't be charged unless you begin setting up servers and putting them live). For testing purposes, you can put them online and then take them down (only $.085 per hour of use for the smallest option") whenever you want.

Once you have set up your account:

    Browse to Home > Resources > AWS Management Console > Amazon EC2

    Browse to "Launch Instance" -> Community AMI's and search -> ami-296e8a40 (this is the smart fox pro AMI you can use to get started)

    Hit "Select" -> Launch Instances -> Create Key Pair (whatever you want, be sure to download it to c:\ec2\) -> Configure Firewall ("default") then Review and create the instance. It will go live after a few minutes and appear in the "instances" section.

IMPORTANT:
    When you create your key pair, you will get ONE chance to download it. Make SURE to download it or else you will have to go through this again. I don't know why but there doesn't seem to be a second chance to download it.
    Download it to C:\ec2\ for now (rename it to a .ppk file (will explain more later)

ALSO VERY IMPORTANT:
    for some reason this will not work with Putty / PuttyGen (later on in the article) unless you add a "/n" to the end of it.
    open up the file in notepad and do this: (note the "/n" at the end of the file (it will look like the below):

-----BEGIN RSA PRIVATE KEY-----
MIIEpQIBAAKCAQEAoYkTqi/qETo3QH4dzTMf7UE7KncoUCT+veohz4QK98FAfEpCbracnEqdOpO/
Ep5iBmg384e++ETbVU270+CRBKpurKrQ2j7Jyj/7MQMitRJLhzYgmJeHpf9Peyetn26EzG6r4Y0q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BifkbH5nllFjmWK8feafyU9Wde7JE1j8kTVXJCBMGC4prpz9LlvqO4j6rECDG
592il5pddqvbYEQtCSNM9JInpxKTh91aVx48tIB0ki+6d+D8/tTeah6n1xp7DkWTcRoNIlHJi3qG
PC0sIrKyFQhcBeiUeywbViaCX3OYDlIi1M6vctgOwR/NRQECgYEAsa3vh8Wxt/S9wL3bpX54j2rP
m2zEZa9A0b0Wv/kAWBRBp63fveLTf2Ox7j1DivXFbL9tVxPeQxae2VasWpIeJPfLLrkmsVuAzWvB
/lxOjF5V9RNfZwTcTeENhdkUc+6i0sG8KdUHDkzJcBhIsaHwcF402mstTdNl0UVs5y/7OMw=
-----END RSA PRIVATE KEY-----
/n

NOTE THAT I ADDED A /N I am not kidding! Save it and close it as a .ppk file. You have to do this or you wont be able to get shell access later on with PuTTY.

Now you need to set up the ability to SSH into your Amazon EC2 account from windows (this gets really ugly)

First, make sure you have created a security certificate:
    aws.amazon.com -> your Account -> Security Credentials -> x.509 Certificates
    Download your certificate and key pair by clicking the "download" button and copy them to c:\ec2\ (or create a new one if you haven't already got one)
    you should have two files that look like this when you download:
    cert-[wholebunchofrandomlettersandnumbers].pem
    pk-[wholebunchofrandomlettersandnumbers].pem

Next, download the following packages and unzip them into c:\ec2\


Now download BOTH puTTY and puTTYGEN (you will need them to start the server via shell commands)
    http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
    Might as well download them both into c:\ec2\

Next, Create the following file: startEC2.bat

REM Path should contain bin\java.exe
set JAVA_HOME="C:\Program Files\java\jre6"

REM Path to Primary Key and Certificate retrieved from AWS
set EC2_PRIVATE_KEY=C:\ec2\pk-wholebunchofrandomlettersandnumbers.pem [CHANGE TO BE YOUR PK-file
set EC2_CERT=C:\ec2\cert-wholebunchofrandomlettersandnumbers.pem {CHANGE TO BE YOUR cert-file

REM Path to EC2 API, subfolders of bin and lib
set EC2_HOME=C:\ec2\ec2-api-tools-1.3-46266
set PATH=%PATH%;%EC2_HOME%\bin

REM Path to ELB API, subfolders of bin and lib
set AWS_ELB_HOME=C:\ec2\ElasticLoadBalancing-1.0.3.4
set PATH=%PATH%;%AWS_ELB_HOME%\bin

REM Path to EC2 AMI, subfolders of bin and lib
set AWS_AMI_HOME=C:\ec2\ec2-ami-tools-1.3-45758
set PATH=%PATH%;%AWS_AMI_HOME%\bin

cls
cmd

Now, open a command prompt (Start -> Run -> CMD)

Browse to c:\ec2\

Run: startEc2.bat

Nothing should happen (it will refresh and say "Microsoft windows blah blah blah" in the console")

Now run the following commands:

ec2-describe-regions

should show this if it is working properly. If it doesn't show this, something is broken - got back and try again.

REGION eu-west-1 ec2.eu-west-1.amazonaws.com
REGION us-east-1 ec2.us-east-1.amazonaws.com
REGION us-west-1 ec2.us-west-1.amazonaws.com

Ok, now we need to enable SSH so we can activate the server.

Run these two commands from the CMD prompt (will only work if you have successfully started the EC2 start.bat file as mentioned above.

ec2-authorize default -p 22 (ssh)
ec2-authorize default -p 80 (and http)

you should get something like this for each:

GROUP DEFAULT
PERMISSION 0.0.0.0.0.0
default ALLOWS tcp 22 22 FROM CIDR

Open PuttyGEN (you have to use PuttyGen to reshape the RSA key so that PuttY will accept it)

go to "Load" -> your .ppk file you downloaded earlier (you know, the key pair that you created when you crearted your first server instance)

You should get "successfully imported blah de blah blah"
now save that back into your EC2 folder (leave the default SSH-2 RSA as is). Save it as a .ppk. Did you remember to add the "/n" I mentioned before? Good.

Now open Putty

Go to -> Connection -> SSH -> Auth

now click "browse" and go get the key file that PuttyGen just outputted
now go to Session

Enter your Amazon EC2 DB DNS location into the "Host" box (should look like:)
xx-xxxx-xxxx-xxxx.compute-1.amazonaws.com
(you can get this from the AWS Console when you click the Instance name in the details that show down below (DNS of your instance)

Now hit "open"

It will prompt you asking for a username. Use: sfsdemo
Password:sfsdemopass

Now you can do this stuff:

You are now successfully logged into the virtual box. Now move to the SmartFoxServer installation:
cd SFS_PRO_1.6.2/Server/and start/stop the server with any of the following commands:
./sfs start (to start the daemon)
./sfs stop (to stop the daemon)
./sfs status (to check the daemon status)
./sfs console (to check launch in the console)
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 22 Dec 2009, 07:47

Hi,
thanks for the step by step guide.
Didn't Amazon recently added web-based admin tools? Last time I visited my account a lot of the once terminal-based operations could be done from the web page.
Are the command line tools still needed?

Also I'd like to remind that we provide an Amazon EC2 AMI for testing.
http://www.smartfoxserver.com/labs/ami/
Lapo
--
gotoAndPlay()
...addicted to flash games
ironchef123
Posts: 4
Joined: 21 Dec 2009, 20:20

Postby ironchef123 » 23 Dec 2009, 18:06

Hey Lapo - thanks for adjusting my formatting.

I have posted a more cleaned up version of this guide on my site: http://www.scanplaygames.com/

Can you send me a link for where I can find the terminal based operations? That would be SOOOO helpful!
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 23 Dec 2009, 22:45

There's no specific link, simply login into your Amazon EC2 admin account and you'll find a lot of tools there (create/remove instances, configuration etc...)

Happy Holidays
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 30 Dec 2009, 16:45

UPDATE: I can also recommend checking this FireFox extension which provides visual management tools for your EC2 instances.
http://architects.dzone.com/news/hybridfox-elasticfox
Lapo

--

gotoAndPlay()

...addicted to flash games
Sappho
Posts: 74
Joined: 29 Mar 2009, 19:23
Location: Slovakia

Postby Sappho » 12 Jan 2010, 23:14

Lapo i've tried the test AMI on Amazon EC2 but it doesn't work at all. I don't know if its a problem with the AMI or with the EC2 service. It goes from pending right to terminated. Any suggestions?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 13 Jan 2010, 06:29

Can you provide more details?
Does the virtual machine start? Can you access it remotely?
Please explain.
Lapo

--

gotoAndPlay()

...addicted to flash games
Sappho
Posts: 74
Joined: 29 Mar 2009, 19:23
Location: Slovakia

Postby Sappho » 13 Jan 2010, 11:05

Nope it doesn't start so its pretty simple to reproduce, i login to AWS console, create new instance by looking for sfs, there are two but one of them is not even valid so i use the one you mention in the post.

AMI: ami-296e8a40
Type of the instance: Small (m1.small 1.7GB)
Availability zone: us-east-1a

I leave everything else on default with new key-pair, firewall default as well. The availability zone i need to specify since thats where my storage is.

So after i create it i can see it in my instance list as Pending. After a minute or so instead of it becoming running it goes straight to Terminated state. As if it failed to run. So nope i can't access it at all. To me it seems more like a problem with EC2 however i can run other instances like the test Fedora ones without problem.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 13 Jan 2010, 16:57

Wow, sad news... it used to work without a flaw. I hope they haven't changed format or something else :(
Is there anyone else having the same issue?

We'll take a look as soon as possible.
Lapo

--

gotoAndPlay()

...addicted to flash games
sbocharov
Posts: 2
Joined: 28 Jan 2010, 16:02
Location: Russia

Postby sbocharov » 28 Jan 2010, 16:12

Lapo i've the same problem with ami-296e8a40 on the us-east-1a

I've tried launch an instance of your AMI, but status - terminated. My other instances work without problem.


Instance console output:

.......
bla bla bla
.......
[74G[ OK ]
* Will now halt
halt: Unable to iterate IDE devices: No such file or directory
System halted.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 28 Jan 2010, 16:38

Thanks. What is your other instance?
Lapo

--

gotoAndPlay()

...addicted to flash games
sbocharov
Posts: 2
Joined: 28 Jan 2010, 16:02
Location: Russia

Postby sbocharov » 28 Jan 2010, 18:02

For example this - ami-2fc2e95b
ubuntu-images-eu/ubuntu-karmic-9.10-i386
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 30 Jan 2010, 09:49

I see, thank you.
It's quite sad that the AMI doesn't work anymore. Evidently Amazon has changed some aspects of their VMs and has rendered our image unusable. I don't think there's other possible explanation.

Unless there's some sort of upgrading system for older AMIs I guess we'll have to rebuild it from scratch. My feeling is that we won't be able to do this in the immediate future as all our team is currently very busy on the next major release. It might take at least a couple of weeks, or more.

In the meantime I can simply suggest to start with a Linux AMI following Amazon's documentation and install SmartFoxServer on it.
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
Carl Lydon
Posts: 298
Joined: 12 Nov 2007, 16:15
Location: NYC
Contact:

Re: Getting SmartFox Server working on Amazon EC2 (GUIDE)

Postby Carl Lydon » 30 Jul 2016, 01:25

Hi,

This is a really old thread, so I wonder if there are any updated tutorials, or does everything mentioned above still stand?

Also, are there any guides for setting this up from a mac?

What is the minimum sized machine that can run smartFox 2X (just for dev and demo purposes):

https://aws.amazon.com/ec2/pricing/

t2.nano, t2.micro, t2.small, t2.medium etc?

Thanks,

Carl
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Getting SmartFox Server working on Amazon EC2 (GUIDE)

Postby Lapo » 30 Jul 2016, 08:49

If you're interested in getting started with SFS2X in the cloud you can take a look here:
http://smartfoxserver.com/cloud

We have partnered with several companies that simplify the deployment process, although it's not particularly complicated to do by hand too. All you need is download the server's installer and run it in your favorite cloud environment.

What is the minimum sized machine that can run smartFox 2X (just for dev and demo purposes):

For dev and testing any VM with 64MBytes of free RAM will do. For production it depends, typically a minimum of 2-core CPU and 2GB of RAM can handle most medium traffic games.

Hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 30 guests