andresfelipemendez / server_hot_reload

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hot Reloadable Web Server with Arena Allocator

This project is a simple web server with hot-reload capabilities, implemented in C++. The server can dynamically reload its shared library (.so file) without restarting, preserving its state using an arena allocator.

runs on ubuntu, inotify tools

Features

  • Hot Reloading: Automatically reloads the shared library when changes are detected.
  • Arena Allocator: Efficient memory management using a custom arena allocator.
  • Persistent State: Maintains server state across library reloads.
  • Simple HTTP Server: Responds with "Hello, World!" to incoming HTTP requests.

Directory Structure

.
├── build
├── buildscripts
│ ├── build_hotreload.sh
│ └── build_lib.sh
├── hotreload
│ ├── arena_allocator.h
│ └── hotreload.cpp
├── lib
├── run.sh
└── src
├── server.cpp
└── server.h

Getting Started

Prerequisites

  • Git: To clone the repository.
  • C++ Compiler: To build the source code (e.g., g++).

Clone the Repository

git clone https://github.com/andresfelipemendez/server_hot_reload.git
cd hot-reloadable-web-server

Building the Project

  1. Build the Shared Library (Server)
./buildscripts/build_lib.sh
  1. Build the Hot Reload Watcher
 ./buildscripts/build_hotreload.sh

Running the Server

./run.sh

Usage

The server will start and listen on port 8080. You can access the server by navigating to http://localhost:8080 in your web browser. The server responds with "Hello, World!".

Hot Reloading

The hot reload watcher will monitor changes to the shared library (enginelib.so). When a change is detected, the library is reloaded without restarting the server, preserving the state using the arena allocator.

Example Output

Server initialized
Server updating
Server updating
DLL updated. Reloading...
Server updating

About


Languages

Language:C++ 99.2%Language:C 0.6%Language:Shell 0.3%