7. Packaging The Game Server

Human errors are the most common cause of game server deployment issues. And most errors are because of improper packaging and versioning: missing required files, copying old version, and so on. So, it’s desirable to package the game server into a single file and to make the steps automated.

iFun Engine provides such a feature to package the game server and to version the generated package with a GIT/SVN commit ID.

7.1. Generating a package

In the build directory, type in make package. Then, you will get a package containing all required files to run your game server. Package can be in either DEB, RPM, or TGZ. Just specify format(s) you want in hello_world-source/CMakeLists.txt. We will specify like below for using Ubuntu.

# Generate a distribution package in tgz?
set(WANT_TGZ_PACKAGE false)

# Generate a distribution package in Debian DEB?
set(WANT_DEB_PACKAGE true)

# Generate a distribution package in Redhat RPM?
set(WANT_RPM_PACKAGE false)

Run make package. And you will see a .deb file is generated.

$ make package
Leveraging ccache. CCACHE=/usr/bin/ccache, CCACHE_DIR=, CCACHE_TEMPDIR=.
/tmp/hello_world-source/etc/upstart/default/hello_world.lobby not found. Skipping.
/tmp/hello_world-source/etc/upstart/init/hello_world.lobby.conf not found. Skipping.
/tmp/hello_world-source/etc/upstart/default/hello_world.game not found. Skipping.
/tmp/hello_world-source/etc/upstart/init/hello_world.game.conf not found. Skipping.
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/hello_world-build/debug
[ 16%] Built target internal_create_launchers
[ 25%] Built target internal_import_manifest_dirs
[ 33%] Built target internal_import_resource_dirs
[100%] Built target hello_world
Run CPack packaging tool...
CPack: Create package using DEB
CPack: Install projects
CPack: - Run preinstall target for: hello_world
CPack: - Install project: hello_world
CPack: -   Install component: game
CPack: -   Install component: lobby
CPack: Create package
CPackDeb: - Generating dependency list
CPackDeb: - Generating dependency list
CPack: - package: /tmp/hello_world-build/debug/hello-world_0.0.1_install-game.deb generated.
CPack: - package: /tmp/hello_world-build/debug/hello-world_0.0.1_install-lobby.deb generated.

$ ls *.deb
hello-world_0.0.1_install-game.deb  hello-world_0.0.1_install-lobby.deb

Tip

Unless you have flavor(s) configured, only one DEB file will be generated, by default. With flavors, one DEB for each flavor will be created.

To deploy server, copy generated DEB file(s) to your real server and install using the dpkg command.

7.2. Giving version and build number to the game server package

The .deb files generated in the previous section has a version number 0.0.1. You might wonder where the number came from. This number is from hello_world-source/VERSION. If you increase the version number in the file to 0.0.2, you will get a package with version 0.0.2.

For version number increase in real life indicates major changes in your game, we ask you to update the VERSION file manually. Then, how to identify each build? You may want to automatically assign a build number to each build. iFun Engine can do this. If you manage your source files by SVN or GIT, iFun Engine uses SVN revision numbers or GIT commit ID as build numbers. So, final version string will look like: 0.0.1-1234.

Open up hello_world-source/CMakeLists.txt and turn on one of the variables following:

# Source managed by git can append a build number from git commit id.
set(PACKAGE_WITH_BUILD_NUMBER_FROM_GIT false)

# Source managed by svn can append a build number from svn info.
set(PACKAGE_WITH_BUILD_NUMBER_FROM_SVN false)

Tip

If you build a package with uncommitted changes, iFun Engine also appends a string dirty. For example, 0.0.1-1234~dirty.