Made in Germany with love ❤ and beer 🍺.
Spikedog is a lightweight open source HTTP server, optimized for web services and good performance.
- Java 21 or higher
Folder Structure:
- directory
- modules
- info-module.jar
- reload-module.jar
- Spikedog.jar
- start.sh
- modules
- Install Java 21 or higher (root required)
sudo apt install openjdk-21-jdk
- Install screen (root required)
sudo apt install screen
- Create an empty directory
mkdir directory cd directory
- Download Spikedog.jar
wget https://github.com/Diruptio/Spikedog/releases/latest/download/Spikedog.jar
- Create start.sh with following content:
screen -dmS spikedog java -jar ./Spikedog.jar
- Make shart.sh executable
chmod +x start
- Start the server
You can attach to the screen using
./start.sh
screen -r spikedog
and detach withCtrl + A + D
. - Autostart (optional)
Add the following line to ~/.profile:directory/start.sh
All modules are located in the modules
directory. The server will load all modules on startup.
If you wish to reload the modules at runtime, download reload-module.jar and place it in the modules
directory.
If you wish to see all loaded modules and sites/servlets at runtime, download info-module.jar and place it in the modules
directory.
If you need to load a module before another module, you can create order.txt
in your modules
directory.
The files in order.txt
will be loaded in the order they are listed and before the non-listed files. You also can use regular expressions in order.txt
.
Maven:
<repositories>
<repository>
<url>https://repo.diruptio.de/repository/maven-public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>diruptio</groupId>
<artifactId>Spikedog</artifactId>
<version>VERSION</version>
</dependency>
</dependencies>
Gradle:
repositories {
maven { url = "https://repo.diruptio.de/repository/maven-public/" }
}
dependencies {
implementation "diruptio:Spikedog:VERSION"
}
You can view the example code or follow this tutorial
- Create a Listener
Your Spikedog Listener must implement theListener
interface. It will be loaded automatically.public class ExampleListener implements Listener { @Override public void onLoad(Module self) { System.out.println("Loading example module"); } @Override public void onUnload() { System.out.println("Unloading example module"); } }
- Create a Servlet
public class ExampleServlet { @Endpoint(path = "/example") public void handle(HttpRequest request, HttpResponse response) { response.content("Hello World!"); } }
- Register your Servlet in the Listener
@Override public void onLoad(Module self) { System.out.println("Loading example module"); Spikedog.register(new ExampleServlet()); }