[Nix-dev] lighttpd service

Rickard Nilsson rickard.nilsson at telia.com
Thu May 31 11:13:31 CEST 2012


Hi Alexander,

I have no troubles running av minimal lighttpd on NixOS. I can start and  
stop it with upstart. My configuration looks like this:

let

   root = "/srv/www";
   httpPort = 3000;

   httpConf = writeText "webserver.conf" ''
     server.document-root = "${root}"
     server.port = ${httpPort}
   '';

in {

   jobs.webserver = {
     path = [ lighttpd ];
     exec = "lighttpd -D -f ${httpConf}";
   };

}


Regards,
   Rickard Nilsson


Den 2012-05-27 16:03:50 skrev Alexander Foremny  
<alexanderforemny at googlemail.com>:

> Hello,
>
> I am still trying to get a minimal Nix expression for Lighttpd to
> work. However, I cannot get the upstart job to behave well. The Nix
> expression for the service so far is available on GitHub [1].
>
> I also uploaded the generated upstart job file [2].
>
> What's strange is that starting / stopping the upstart job seems to
> hang forever. For instance
>
>> # initctl status lighttpd
>> lighttpd stop/waiting
>> # initctl start lighttpd
>> [ here it hangs forever ]
>
> In another terminal I can see that Lighttpd in fact is successfully
> started by upstart.
>
>> # initctl status lighttpd
>> lighttpd start/spawned, process 4803
>
> ps reports that the PID inferred by upstart is correct. I then Ctrl-C
> out of the hanging initctl start lighttpd. However, trying to initctl
> stop the lighttpd job it hangs again without any output. A strace
> gives the following last lines.
>
>> # strace initctl stop lighttpd
>> recvmsg(3, 0xbffe2b9c, MSG_CMSG_CLOEXEC) = -1 EAGAIN (Resource  
>> temporarily unavailable)
>> clock_gettime(CLOCK_MONOTONIC, {1782, 252572560}) = 0
>> poll([{fd=3, events=POLLIN}], 1, -1
>
> However, this time the Lighttpd server process is not being terminated
> by upstart! I tried increasing upstart's log verbosity without gaining
> any additional insight.
>
> Does anyone of you have an idea of what's going on? Any help would
> greatly be appreciated.
>
> Regards,
> Alexander Foremny
>
> [1]  
> https://github.com/aforemny/nixos/blob/master/modules/services/web-servers/lighttpd/default.nix
> [2] https://gist.github.com/2814308
>
> 2012/5/24 Nicolas Pierron <nicolas.b.pierron at gmail.com>:
>> Hi,
>>
>> On Tue, May 22, 2012 at 3:13 PM, Alexander Foremny
>> <alexanderforemny at googlemail.com> wrote:
>>> I am trying to write a service module for lighttpd. I came up with a
>>> minimal example [1] which is giving me the following error upon
>>> rebuilding my system.
>>
>> Nice.  I would be happy to see that.
>>
>>> How can I make my option services.lighttpd known to NixOS?
>>
>> Every NixOS file, even your configuration.nix is a module, this means
>> that you don't have to build against a custom version of NixOS unless
>> you want to modify some of its files.  If you just want to *add* a new
>> module, I will recommend you to use the "require" or "imports"
>> attribute in your configuration.nix.
>>
>> So your /etc/nixos/configuration.nix should look like:
>>
>> {
>>  require = [
>>    lighttpd/default.nix
>>  ];
>>
>>>>
>> }
>>
>> The syntax of module is documented in the wiki[1] for more detail.
>>
>> [1] http://nixos.org/wiki/NixOS:Modules
>>
>> --
>> Nicolas Pierron
>> http://www.linkedin.com/in/nicolasbpierron - http://nbp.name/
> _______________________________________________
> nix-dev mailing list
> nix-dev at lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev


More information about the nix-dev mailing list