Table of Contents
C++ application server module for apache2
This is a module for apache2 whiche enables compilation, loading and execution of C++ classes and HTML pages with c++ embeded. I work on this module for several
years and I use it in prod uction on several applications (both professionally
and personally). It is stable and reactive. Web applications development is very pleasant and quite fast.
Here is a list of features and characteristics.
- seamlessly integrates the Apache's operation and configurations directives ;
- applications you develop are composed of .C (your controller) and .csp (your
views) directly inside your web directories, heade files and/or libraries (your model) can be found elsewhere ;
- controllers (.C) and views (.csp) are compiled and loaded on the fly when
the corresponding binary object is outdated. The server has not to be restarted too often ;
- Each source file contains a class that inherits from HttpServlet and only overloads
service(req,resp) (or doGet, doPost...) ;
- raiipp preprocessor takes care of converting .csp files containing mainly html
code into a class that inherits from HttpServlet ;
- syntax used by the preprocessor is similar to JSP - you can also use personalized tags ;
- Untrapped exceptions are displayed in the web page with the stack unwinded to
display functions names, source files and line numbers for easy debugging. Besides the com the compilation errors are alos exceptions and are displayed with pretty colors ;
- signals "Illegal Instruction", "Floating Point Exception", "Segmentation Violation",
"Bus Error" et "Abort" are intercepted weither they come from a request or not, and are detailed and processed like exceptions which are displayed. This prevents the server to die (there are limits anyway...) ;
- connection to a lot of database via sqlrelay ;
- or to PostgreSQL natively with internalt connection pool ;
- or to SQLite with the same mechanism ;
- or the database you love, two classes are to be overloaded (15 trival methods in total)
to implement a database driver
- some of the STL classes are overloaded (crappy but effective) so you can embed them in sessions
Because I found j2ee concept very interesting, because the Java running environment is not within reach of a Cobalt Qube with only 64 MB of memory (also try to run a php page on a Cobalt Qube... and I'm not talking about RoR).
Api is similar to that provided by javax.servlet.http. But unlike Java, C++ does not have a garbage collector, you should see this as an advantage because the use of smart pointers with reference counting can safely manage memory allocation (see the Raii idiom).
A debian (tested on mips (el), powerpc, i686 and amd64), with packages g++, libapache2-mod-apreq2, libapreq2, libapreq2-dev, apache2-mpm-worker (or apache2-mpm-event), apache2-threaded-dev, libapr1, libapr1-dev, libvmime0, and libvmime-dev. For database connectors libsqlite0, libsqlite0-dev, sqlite, libpq5 et libpq-dev.
Actualy not a screenshot but pieces of programs
a controler ( /ctrl.C ) :
a view ( /view/index.csp ) :
If you do not have su0 :
Then you need to tell apache that there is a new module to load (without forgetting to turn on apreq)
Because the operation of this module, you must use mpm-worker or mpm-event version of apache and run a single server process. However, there is no limitation on the number of threads (take care of the memory used by each thread's stack). This give the file /etc/apache2/apache2.conf
and finally restart apache :
You can install Not So Original, a photo gallery that processe your raw files, TinyCMS or loudspeaker.
In case of problems, please drop a mail to me. " guillaume AT blackmilk o fr".