Skip to content

Firefly Environment Setting Up

9miao Mobile Game edited this page Aug 5, 2014 · 1 revision

Firefly Environment Setting Up

One Python Installation

Firefly is a high-performance, distributed game server framework written in Python, so installing Python is a prerequisite for using Firefly.

Python has its corresponding version of Linux, Windows and other operating system, and could work properly in any OS. It has a cross-platform feature with the exception of platform-related functions or platform-specific libraries user needs.

1. Install Python in Windows

1) Download Python version of your OS (download from: http://www.python.org/)
2) Always click “next” during installation with only one caution: keeping in mind the installation path.
3) Configure environment variables.
A. find the path in system variables

B. Edit path value, add Python installation path.

C. Open cmd and input Python to check its installation condition, if the follow screen appears, your Python was successfully installed.

2. Install Python in Linux

1) Download Python version of your OS (download from: http://www.python.org/)
2) It’s also an easy work to install, here python2.7.3 as example (source package name: Python-2.7.3.tar.bz2)

Installation command
$ tar –jxvf Python-2.7.3.tar.bz2
$ cd Python-2.7.3
$ ./configure
$ make
$ make install

3) Input Python in terminal to test, if the follow screen appears, your Python was successfully installed.

Two Memcached Installation

Firefly employs memcached cache system and stores general information in it for the purpose of avoiding frequent interaction with the database. It significantly reduces the number of interaction between server-side and database and improves performance.

1. Install Memcached in Windows

1) Download memcached for windows (only source code is available on official site, but there are many third-party compiled windows version), and then unzip to a disk, such as c:\memcached
2) Input “c:\memcached\memcached.exe -d install” in cmd to install.
3) Input “c:\memcached\memcached.exe -d start” to launch, by doing so memcached will start automatically at each boot as a service of Windows. So server-side’s installation is completed.
4) All the aforementioned installation steps are conducted under default environment, you can set the below parameters when installing:
-p monitoring port
-l attached IP address, default native
-d start start memcached service
-d restart restart memcached service
-d stop|shutdown close the running memcached service
-d install install memcached service
-d uninstall uninstall memcached service
-u run as……(only valid when it’s run as root)
-m peak memory usage, MB unit, 64MB default
-M return error when memory is exhausted, not delete item
-c maximum simultaneous connections number, 1024 default
-f block size growth factor, 1.25 default
-n the minimum allocation of space, key+value+flags 48 default
-h help
“memcached -d install -l 127.0.0.1 -m 1024 -c 2048”means attaching IP 127.0.0.1, peak memory usage 1024MB, maximum simultaneous connections 2048.

If parameter was not added in installation, you can set it by modifying registry. Open registry, and find:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\memcached Server

Add your parameter in data column of ImagePath.

2. Install Memcached in Linux

1) Memcache adopts libevent for Socket processing, so your Linux needs to install libevent. (If your OS is already installed libevent, then pass this step)
You can download the required version from libevent official website (http://libevent.org/)

Here we take version 1.2 as example
tar zxvf libevent-1.2.tar.gz
cd libevent-1.2
./configure –prefix=/usr
make
make install
test the installation condition:
ls -al /usr/lib | grep libevent

2) Download memcached. (you can download from libevent official website http://libevent.org/)
3) Install memcached
tar zxvf memcached-1.2.0.tar.gz
cd memcached-1.2.0
./configure –with-libevent=/usr
make
make install

If there are error reports, please go through the errors message, configure or add corresponding library or path according to these messages.
The path of memcached after installation: /usr/local/bin/memcached
4) Test the memcached installation

ls -al /usr/local/bin/mem*