Lightweight, single threaded http and websockets server, completely written in C.
It does preallocate necessary resources for predetermined maximum number of connections.
Memory footprint stays pretty much the same over the time
Static content is stored in <binaryname>.web.data and <binaryname>.web.index files in <binarypath>/data directory.
- <binarypath>/data/<binaryname>.web.data
- Both compressed and uncompressed web content.
- <binarypath>/data/<binaryname>.web.index
- Simple, fast specialized btree index of content file names.
- To create or update these files mkcache service program must be used.
- Server checks modification time of these files periodically.
- If it is changed it loads them to memory, starts serving them and frees the last one seamlessly.
- This is the only condition malloc and free used after program start.
- When you run mkcache
- It scans all files in <sourcepath> matching extensions in <mkcachepath>/mime.types file.
- mime.types
- <0|1> <mime type> <extension> ...
- 0 : Do not compress
- 1 : Compress
- If file is marked for compression and compression gain is more than %40, stores both compressed and uncompressed content.
- Otherwise it just stores uncompressed content.
- Then generated temporary files are moved to <cachepath>.
- About command line parameters
- Command line parameters are stored in a /conf/.cnf file.
- Once program is run with no parameters given, default values are stored. If you supply a valig parameter it will be stored in this file.
- It parses and stores valid program parameters.
- It reads rest of the valid parameters from config file.
- If no value of parameter is not stored in the config file, assigns hardcoded default value and stores.
- Most common parameters
- -v // Not stored
- Prints version and build number (auto generated by version.h and time of build), and exits.
- eg. 1.1.D20170513T011707
- -a // not stored
- Prints app name (hardcoded internal application name) and exits
- -va // not stored
- Prints app name and version and exits.
- daemon=<1|0> // stored
- 1 : Run as a daemon. Uses daemon(1, 0) library call.
- In daemon mode all log messages are directed to syslog. So avoid dumping unnecessary messages, keep your log clean and meaningful.