• Examples (iOS)
• Examples (Java/Android)
• Examples (C++)
Server API Documentation

 

» Installing under Linux

Download the Linux .tar.gz distribution and, open a terminal window and follow these steps:

Example:

$ cd /home/fozzie
$ tar xf SFS2X_unix_2_12_0.tar.gzz

» Running SmartFoxServer 2X

You can run SFS2X as a service using the sfs2x-service script. It provides the following switches:

In order to start SmartFoxServer, move to the installation folder and start the server with: ./sfs2x-service start
For example:

$ cd /home/fozzie/SmartFoxServer_2X/SFS2X/
$ ./sfs2x-service start

If any startup problem should occur, you can check the log files under {sfs-install-dir}/logs and {sfs-install-dir}/logs/boot.

In alternative you can execute the sfs2x script to run the server in standalone mode and see the logs directly in the terminal (useful for development). For example:

$ cd /home/fozzie/SmartFoxServer_2X/SFS2X/
$ ./sfs2x.sh

» Uninstalling SmartFoxServer 2X

In order to completely remove SFS2X from your system proceed as follows:

Please notice that this operation is not reversible and all server settings will be lost.

» Configuring the OS file descriptors limit

Under Linux file descriptors are used to abstract not only open files but also socket connections. If your SFS2X application receives a lot of traffic it might start complaining with a "Too many open files" error.

By default most Linux distributions are set to a maximum of 1024 file descriptors: each time you open a file or a socket connection you use one of these descriptors and when you reach the limit you will get the error mentioned above. To check the value currently set in your system you can type this command in a terminal window:

ulimit -n

The value returned by the command is the current limit for all open files and sockets, for the current user. In order to reconfigure your system to handle more connections we highly recommend following this external tutorial.

» Using port numbers <= 1024

Under Linux and Unix running the server on port numbers less than or equal to 1024 requires root privileges.

» Installing SmartFoxServer 2X as a daemon

To install a service as daemon you will need to determine the type of init process used in your Linux distribution. We recommend reading this external article to determine the type of init system from console.

1) SystemV init

In order to install SFS2X as a daemon you will need root priviliges.

The simplest method is to move to the /etc/rcX.d folder (where X is your current runlevel). From there type: ln -s {path-to-sfs2x-service-script} S99sfs2X
This will create a symbolic link to the start script in the rcX.d folder. On the next restart the server will be launched as a daemon.

For example, supposing you have root privileges and your runlevel is 5 (multiuser mode + GUI):

$ cd /etc/rc5.d
$ ln -s /home/fozzie/SmartFoxServer_2X/SFS2X/sfs2x-service S99sfs2X

Once you reboot the machine you should find SmartFoxServer 2X running at startup.

2) Systemd init

You will need to create a new file under /lib/systemd/system/ called, for example, smartfox.service.
Then edit and paste the following configuration, making sure to change all the path references to the correct folders in your system.

 
[Unit]
Description=SmartFoxServer 2X
After=network.target

[Service]
Type=forking
User=root
LimitNOFILE=100000
WorkingDirectory=/path/to/SmartFoxServer_2X/SFS2X
ExecStart=/path/to/SmartFoxServer_2X/SFS2X/sfs2x-service start
ExecStop=/path/to/SmartFoxServer_2X/SFS2X/sfs2x-service stop
Restart=on-abort

[Install]
WantedBy=multi-user.target

Finally you will need to activate the service via this command:

sudo systemctl enable smartfox.service

Once you reboot the machine you should find SmartFoxServer 2X running at startup.

NOTE: you can replace the "root" user in the configuration with another user, provided it has enough privileges to run the server.

« previous page