Installing and running on AWS EC2

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

wilprim
Posts: 6
Joined: 19 Jan 2018, 18:37

Installing and running on AWS EC2

Postby wilprim » 23 Jan 2018, 02:38

Hi there, I am wondering how I can install and run SFS2x on a AWS EC2 Linux Instance. I have looked everywhere online but there is really nothing showing a beginner how to do this...

Basically what I have tried (might sound really dumb) is:

1. I ssh into my instance

2. scp the .tar.gz file and then extract it to my /home/ec2-user/ dir

3. try to run the sfs2x-service

This obviously didn't work. I get the error in my logs saying that it couldn't bind socket to port:

Code: Select all

03:39:16,852 INFO  [main] core.AdminToolService     - AdminTool Service started
03:39:16,891 WARN  [main] bootLogger     - Was not able to bind socket: { 0.0.0.0:9933, (Tcp) }
03:39:16,898 WARN  [main] bootLogger     - Was not able to bind socket: { 127.0.0.1:9933, (Udp) }


My instance security group is:

Code: Select all

80   tcp   0.0.0.0/0, ::/0   
22   tcp   0.0.0.0/0   
9933   tcp   0.0.0.0/0


I just want a beginners guide to doing this and maybe some pointers to get me started on the right path. I want to use AWS ec2 for learning and experience purposes...
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Installing and running on AWS EC2

Postby Lapo » 23 Jan 2018, 09:36

Hi,
it should be pretty simple.
I'd recommend using Ubuntu if you're ok with running Linux. You can start a machine with a Ubuntu AMI then as you correctly said, you download the SFS2X binaries and unzip them.

Then you 'cd' into SmartFoxServer_2X/SFS2X/ folder and start it with:

Code: Select all

./sfs2x-service start


03:39:16,891 WARN [main] bootLogger - Was not able to bind socket: { 0.0.0.0:9933, (Tcp) }
03:39:16,898 WARN [main] bootLogger - Was not able to bind socket: { 127.0.0.1:9933, (Udp) }

This is very weird.
I have no idea why it would fail to bind the network unless you're already running another SFS2X.
Can you please double check?

Finally you need to configure the Security Group, which is essentially a bunch of firewall rules: in the Inbound settings you need to open port TCP 9933, UDP 9933, TCP 8080, TCP 8443 (if you need HTTPS) and TCP 22 (if you need SSH access)

Let me know how it goes.
Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
wilprim
Posts: 6
Joined: 19 Jan 2018, 18:37

Re: Installing and running on AWS EC2

Postby wilprim » 23 Jan 2018, 16:54

Hey Lapo, yes there was another instance running in the background :P. I forgot that I ran ./sfs2x-service start right when I logged in and then to see the logs i ran ./sfs2x.sh

Now that it is running,

1. how can I check the status of SFS from SSH as I don't know how to tell if it is even running...
2. How do i access the /admin page to login to remote admin? I have installed httpd (apache server) and opened up port 80 to http to be able to view web pages but I can't seem to figure out how to access that page..

Thanks for all the help!
votagusvotag
Posts: 38
Joined: 07 Nov 2016, 12:26

Re: Installing and running on AWS EC2

Postby votagusvotag » 24 Jan 2018, 18:27

Hi, we use htop to see if the server is running and a script .sh in the crontab to check if the server is running every minute and try to start if it is not.

* * * * * /home/ubuntu/SmartFoxServer_2X/SFS2X/service-check.sh >> /home/ubuntu/SmartFoxServer_2X/SFS2X/service-status 2>&1

Code: Select all

#!/bin/bash
service=./SmartFoxServer_2X/SFS2X/sfs2x-service

if (( $(ps -ef | grep -v grep | grep sfs2x | wc -l) > 0 ))
then
echo "$service is running!!!"; date
else
$service start
fi


To start the admin you just have to go to <ec2publicip>:8080. Hope it helps.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Installing and running on AWS EC2

Postby Lapo » 25 Jan 2018, 14:44

wilprim wrote:1. how can I check the status of SFS from SSH as I don't know how to tell if it is even running...

With this:

Code: Select all

./sfs2x-service status


2. How do i access the /admin page to login to remote admin? I have installed httpd (apache server) and opened up port 80 to http to be able to view web pages but I can't seem to figure out how to access that page..

You don't need a separate HTTP server for that. SFS2X runs its own (Jetty)
you just need to point your browser to http://<your-domain>:8080

I'd suggest to review the installation docs:
http://docs2x.smartfoxserver.com/Gettin ... stallation

See the last section, at the bottom
Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
wilprim
Posts: 6
Joined: 19 Jan 2018, 18:37

Re: Installing and running on AWS EC2

Postby wilprim » 27 Jan 2018, 05:12

Thanks for all the help. I got it to work. I guess I was just over complicating it a ton... lol

But basically here is what I did:

I downloaded the .tar.gz SFS file and put it into my main user folder on AWS ec2 using (scp) secure copy:

Code: Select all

$ -> scp -i KEY.pem ssf2x.tar.gz ubuntu@EC2ADDRESS:~


I then extracted the .tar.gz file on my server

Then I cd into SmartFoxServer_2X/SFS2X/ and then ran ./sfs2x-service start to start smart fox.

I then added these inbound rules to my security group:

80 tcp 0.0.0.0/0, ::/0
8080 tcp 0.0.0.0/0, ::/0
9933 tcp 0.0.0.0/0, ::/0
9933 udp 0.0.0.0/0, ::/0

If you then go to: YOURPUBLICIP:8080 you should see the sfs page...

Hope this helps anyone else..
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Installing and running on AWS EC2

Postby Lapo » 29 Jan 2018, 10:17

Well done.
There's even a simpler way. Instead of downloading the SFS2X installer and then uploading it on the server, you can download it directly from the AWS instance by using wget. You just need to copy the download link from our download page and then add it in front of the wget command. It will download the installer locally and voilà. :)

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Google [Bot] and 67 guests