From 0bac13f6b405507ac8ff5f4bb598440cd5e94fd6 Mon Sep 17 00:00:00 2001 From: Glenn Strauss Date: Sat, 24 Nov 2018 14:41:27 -0500 Subject: [PATCH] [core] cygwin sample to run lighttpd under NSSM configure NSSM to set environment variables when starting lighttpd NSSM_SERVICE_NAME=lighttpd NSSM_SERVICE_DIR=/lighttpd/install/dir (optional) --- src/server.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/server.c b/src/server.c index 5a16dd9e..68b74c2c 100644 --- a/src/server.c +++ b/src/server.c @@ -1049,6 +1049,19 @@ static int server_main (server * const srv, int argc, char **argv) { } } + #ifdef __CYGWIN__ + if (!srv->config_storage && NULL != getenv("NSSM_SERVICE_NAME")) { + char *dir = getenv("NSSM_SERVICE_DIR"); + if (NULL != dir && 0 != chdir(dir)) { + log_error_write(srv, __FILE__, __LINE__, "sss", "chdir failed:", dir, strerror(errno)); + return -1; + } + srv->srvconf.dont_daemonize = 1; + buffer_copy_string_len(srv->srvconf.modules_dir, CONST_STR_LEN("modules")); + if (config_read(srv, "conf/lighttpd.conf")) return -1; + } + #endif + if (!srv->config_storage) { log_error_write(srv, __FILE__, __LINE__, "s", "No configuration available. Try using -f option.");