Feedback

Frequently Asked Questions

Never memorize something that you can look up. Albert Einstein


G-WAN does not run (no error message)

δ

On Linux 64-bit, you have to use G-WAN 64-bit. On Linux 32-bit use G-WAN 32-bit. IP tables or SELinux can also block G-WAN.

On Linux 64-bit, when using G-WAN 32-bit, you will need:

 sudo apt-get install ia32-libs libc6-dev-i386

G-WAN stopped unexpectedly

δ

You would not use a Beta version of an OS for a production server, right? Use G-WAN on long-term releases (the Ubuntu versions marked as "LTS"). If you experience a problem with a Linux LTS version, then, please drop us a line.


"loading > error 8246"

δ

One common reason is that you are using an old version of GLIBC. GLIBC 2.14 is the current stable version. G-WAN requires at least GLIBC 2.11. Upgrade to Debian 6.0 or Ubuntu 10.04 for example.

Another reason can be that G-WAN could not use the /tmp directory to store temporary compilation files. The most likely reason is that the 'x' (execute) bit has been disabled for security reasons. The workaround is either to:


No Listener

δ

Rather than using configuration files, Listeners and Hosts are defined by using a specific syntax for the G-WAN sub-folder names:

 / gwan / 0.0.0.0_8080 / #0.0.0.0 / www       for HTML and image files
    |         |               |   / logs      for log files
    |	listening on this     |   / handlers  for Handlers
    |	interface (any) and   |   / csp       for C scripts
    |	port number 8080      |   / cert      for SSL certificates
    |                         |
    |             Host name (like domain.com)
 where the gwan   or IP address (like 192.168.2.4)
 executable is    (one “#”-prefixed root host and
 located          several “$”-prefixed virtual hosts)

For each Listener tied to an interface and port, you will define one single (#-prefixed) root Host and, optionally, one or several additional ($-prefixed) virtual Hosts:

 listener 1: / gwan / 192.168.2.4_80 / #192.168.2.4    (root host)
                                     / $forum.gwan.ch  (virtual host)

 listener 2: / gwan / 192.168.4.8_80 / #192.168.4.8    (root host)
                                     / $gwan.com       (virtual host)

An Alias lets you assign additional domain names to an existing (root or virtual) Host (folder contents, if any, are ignored):

 / gwan / 94.230.210.136_80 / #94.230.210.136                (root host)
                            / #94.230.210.136:gwan.ch        (alias)
                            / #94.230.210.136:gwan.com       (alias)
                            / #94.230.210.136:trustleap.ch   (alias)
                            / #94.230.210.136:trustleap.com  (alias)

Breaking the syntax breaks the feature. Respect the syntax and the 'no listener' error message will go away.


Missing Headers

δ

You need to install missing library headers. Here is an example for libc:

Linux 64-bit running G-WAN 32-bit:

 sudo apt-get -y install libc6-dev-i386

Linux 32-bit or 64-bit:

 sudo apt-get -y install libc6-dev

To find which package contains a given header file, install apt-file (available on Debian systems like Ubuntu):

 sudo apt-get -y install apt-file             // install the apt-file tool
 apt-file update                              // load apt-file's definitions

Then use apt-file as follows:

 apt-file search sqlite3.h                    // search the missing header
 libsqlite3-dev: /usr/include/sqlite3.h       // here is where it can be found
 
 sudo apt-get install libsqlite3-dev          // install the missing package

Undefined Symbol

δ

A library used by a C script with the #pragma link directive – or a system library – cannot be found by the linker.

Use apt-get to install the missing dependencies: on 64-bit systems it downloads and installs libraries needed for 64-bit programs (on 32-bit systems it downloads and installs libraries needed for 32-bit programs).

Here is how to install the mysql client library:

 sudo apt-get install libmysqlclient

You will also need to install the library headers for development:

 sudo apt-get install libmysqlclient-dev

Sometimes, a library is not properly installed. For example, SQLite3 may be stored on disk as /usr/lib/libsqlite3.so.0.8.6 and /usr/lib/libsqlite3.so.0 but not as /usr/lib/libsqlite3.so which is the required form (usually a file system symbolic link or a hard link) to let applications find the library without knowing the library.so[.major.minor] version name. The solution is then to create the missing link:

 sudo ln /usr/lib/libsqlite3.so.0 /usr/lib/libsqlite3.so

Using Libraries

δ

On Linux, /usr/lib lists more than 1,000 pre-installed libraries. Millions of C libraries have been written in 40 years. G-WAN lets you use any of them by adding the #pragma link and #pragma include directives at the top of your C scripts:

#pragma link "sqlite3"                // link with the SQLite3 library
#pragma include "./libraries/sqlite3" // PATH to the SQLite3 headers

#include "sqlite3.h"                  // SQLite3
#include "gwan.h"                     // G-WAN

int main(int argc, char *argv[]) 
{

You must link 32-bit libraries to a 32-bit process and 64-bit libraries to a 64-bit process. To know how a given library was compiled, use the command below:

 file /usr/lib/libsqlite3.so.0.8.6
 /usr/lib/libsqlite3.so.0.8.6: ELF 64-bit LSB shared object...

C++ libraries can be used from C programs by using an extern "C" {} wrapper around the functions that they export. This is neded because C++ is adding a non-standard (different for each C++ compiler) prefix before every function name to distinguish overloaded functions using the same name with different types or number of arguments (Google "C++ mangling" for more details).


Platforms

δ

Initially, G-WAN was written for Windows (where G-WAN, an user-mode process, was 2-5x faster than IIS 7, a kernel module).

Since the G-WAN/Linux v1 port proved to be 2-3x faster than G-WAN/Windows v1, the Windows branch was discontinued.

Since then, G-WAN has greatly improved on speed and features, and is successfully used on many other Linux distributions. If you wish to see G-WAN running on a new platform (OS and/or CPUs) then contact us.


Benchmarks

δ

Benchmarks are the only way to know if your application works – and how well it works. Here is how to install Weighttp (a good multi-threaded ApacheBench replacement).

Here is a couple of benchmark examples and there a benchmark how-to.

I also wrote a wrapper for AB and Weighttp which you can see exercised with Nginx, Lighttpd and Varnish to test the scalability, performance and resource utilization (CPU and memory) of each server.

The ApacheBench (AB) client is using one worker thread. Therefore, AB cannot saturate a server using several threads like G-WAN. To saturate G-WAN you must use a multi-threaded client like Weighttp (in this case, on a single 6-Core CPU, G-WAN is 4x faster than Nginx used with one worker per CPU Core – the server architecture since 2004).

To test G-WAN with AB, configure G-WAN to use one single server worker thread: rename the gwan executable into gwan_1. Then, G-WAN will act as a single-threaded server (and it will shine in AB tests, being 2.5x faster than Nginx used with one worker – the server architecture before 2004).

Many single-threaded servers 'prefer' AB tests for this sole reason: that's the only way for them to 'beat' modern SMP servers in benchmarks. Now you know how to configure G-WAN to rule in all the situations (single thread and SMP tests).


Changing the PATH

δ

You have to change the PATH variable if you want to call programs without specifying their location.

The PATH is defined in the file /etc/profile. It applies to all users. This is a colon-separated list of directories that you can list as follows:

 $PATH
 /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

Edit the PATH as follows:

 sudo gedit /etc/profile

After modification, reload the PATH:

 . /etc/profile
 or
 source /etc/profile

You can find the PATH of a program (covered by PATH) by typing:

 type apache2
 apache2 is /usr/sbin/apache2

Service Mode

δ

To start G-WAN as a service (make it start automatically at boot time) use the script below:

#! /bin/sh
### BEGIN INIT INFO
# Provides:          TrustLeap G-WAN Webserver
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: TrustLeap G-WAN initscript
# Description:       This initiscript starts and stops TrustLeap G-WAN
### END INIT INFO

# Author: Thomas Meitz, gwan at jproxx dot com
# Note:   (edit GWAN_PATH if gwan isn't installed in /usr/local/gwan)

PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local
NAME=gwan
GWAN_PATH=/usr/local/gwan
START="-d"
STOP="-k"
SCRIPTNAME=/etc/init.d/$NAME
STARTMESG="Starting TrustLeap G-WAN Webserver."
UPMESG="$NAME is alive."
DOWNMESG="$NAME is not running."
STATUS=`pidof $NAME`

# Exit if G-WAN is not installed
[ -x "$GWAN_PATH/$NAME" ] || exit 0

case "$1" in
  start)
	echo $STARTMESG
	cd $GWAN_PATH 
	./$NAME $START
	;;
  stop)
        cd $GWAN_PATH
	./$NAME $STOP 
	;;
  status)
        if [ "$STATUS" > 0 ] ; then
          echo $UPMESG
        else
          echo $DOWNMESG
        fi 
        ;;
  restart)
        cd $GWAN_PATH
        ./$NAME $STOP
	echo $STARTMESG
        ./$NAME $START
        ;;
  *)
	echo "Usage: $SCRIPTNAME {start|status|restart|stop}" >&2
	exit 3
	;;
esac

:

To install the script above under /etc/init.d/gwan and run it (under Ubuntu):

gksudo gedit /etc/init.d/gwan       (paste the script above and save the file)
sudo chmod 755 /etc/init.d/gwan     (change the file access rights) 
sudo update-rc.d gwan defaults      (after this, reboot)
sudo service gwan start             (start the gwan service)

Programming Languages

δ

For Java, use the OpenJDK or the SUN/Oracle JVM. G-WAN + OpenJDK has a 21 MB footprint on Linux Ubuntu 10.10 64-bit (the JVM is loaded only if a /csp folder contains *.java scripts).

Objective-C/C++ requires the following dependencies:

sudo apt-get install gobjc gnustep gnustep-devel

If, when compiling, you get the kind of errors below:

 Foundation/NSObject.h: No such file or directory

Then, create the links below:

sudo ln -s /usr/include/GNUstep/Foundation /usr/include/Foundation
sudo ln -s /usr/include/GNUstep/GNUstepBase /usr/include/GNUstepBase
sudo ln -s /usr/include/GNUstep/ObjectiveC2 /usr/include/ObjectiveC2

The D programming language requires you to write "extern (C)" before all (translated in D) gwan.h prototypes (see the hello.d example). The D import replacement for the C include directive could probably be used – if only its file-system mapping was documented). Any help in this matter is appreciated.

A suggestion to enhance these FAQs? Let us know.

Questions Not Answered Here

δ

The G-WAN Forum lets you search for replies to common questions, as well as ask your own questions about how to use G-WAN (reading is free but to preserve the quality of this resource, posting is only available to paying users).

For questions that are not of public interest, contact us.