reserved 1.0.0

A minimal library to run your D application on your webserver using scgi

To use this package, put the following dependency into your project's dependencies section:



A scgi client for D programming language. Doc: dpldocs

The simple way

import reserved;
import std.stdio;

private void response(Request req, Output output)
   output ~= "Hello ";
   if ("name" in req.get) 
      output ~= req.get["name"];
      output ~= "World";

mixin Reserved!"awesome_d_webservice";

Starting this example will create a socket named `/tmp/run/awesome_d_webservice/listener.0.sock`. If another process is still running on the same socket it will be (gracefully) killed.

Configure the server

To make nginx (for example) working with reserved just add these lines on its config file (on ubuntu: `/etc/nginx/sites-available/default`) and restart nginx:

location / {
                include   scgi_params;
                scgi_pass unix:/tmp/run/awesome_d_webservice/listener.0.sock;

Pay attention to sock file permission. Both your application and nginx must have permission to read/write that file. The easy way is to run both with the same user.

Init function

If you need to call a one-time-init function, you can annotate it with `@ReservedInit`. Its signature must be one of these:

bool init()

// will be called using main() args
bool init(string[] args)

It musts return true on success.

Multiple responders

If you want to run multiple parallel responders, just use `-i options on command line. For example ./your_app -i 3 will create a socket named /tmp/run/awesome_d_webservice/listener.3.sock` and/or will kill any process running on it.

  • Andrea Fontana
1.0.0 2018-May-16
~master 2018-May-16
Show all 2 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 1 downloads this month

  • 1 downloads total

Short URL: