Commit Graph

15 Commits

Author SHA1 Message Date
Alberic Corniere
8a1b2f0d4c More compact syntax 2022-12-27 09:41:39 +01:00
Alberic Corniere
86f224bcf4 Set stratup time with env NATS_STARTUP_DELAY
The startup delay when starting as a service under windows was set to 10
seconds.

This value was fixed and hardcoded since before JetStream. On (some)
Windows systems, this leads to service startup failures, as the store
dir sorting may be hindered by an important load, or slowed down by
increased accesses times, typically from security software influence.

This commit allows overriding the startup delay using an environment
variable NATS_STARTUP_DELAY. This variable is checked outside init() to
allow reporting into the service log.

Any value can be used (even lower than the initial 10s). Bare NATS
start can be far faster than 10s. Ops may want to setup this env var to
lower values in order to trigger an error on stricter constraints.
2022-12-26 11:02:53 +01:00
Laurens Vergote
831dc7a4f8 Allow nats-server to run as system user on Windows
Trying to run nats-server as nt authority/system user, the process would immediately exit with error: "The service process could not connect to the service controller."
This is now fixed
2022-04-11 12:12:01 +02:00
Ivan Kozlovic
bdf5cf63b3 Shutdown on Ctrl+C
Changed code on Windows to not use svc code if running in interactive
mode. The original code was running svc.debug.Run() which uses service
code (Execute()) but from the command line. We don't need that.

Also reduced salt on bcrypt password for a config file that started
to cause failures due to test taking too long to finish.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-11-14 20:05:32 -07:00
Derek Collison
acfe372d63 Changes for rename from gnatsd -> nats-server
Signed-off-by: Derek Collison <derek@nats.io>
2019-05-06 15:04:24 -07:00
Ivan Kozlovic
c173d55e2e Update based on comments
Start the lame duck mode in a go routine in the signal handler
because I think we want to be able to shutdown the server while
in that mode.

Kept the closing as a loop in the lameDuckMode() function (did
not use a timer).

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2018-10-22 16:27:30 -06:00
Ivan Kozlovic
0067c3bb04 Added support for lame duck mode
When receiving SIGUSR2 signal (or -sl ldm) the server stops
accepting new clients, closes routes connections and spread the
closing of client connections based on a config lame duck duration
(default is 30sec). This will help preventing a storm of client
reconnect when a server needs to be shutdown.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2018-10-19 19:07:37 -06:00
Ivan Kozlovic
2153a45050 Update service and syslog code to use variable instead of constant
for the process name and service name. This allows the reuse of this
code in NATS Streaming Server by invoking the new setters to
change the service and process names.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2018-08-16 10:21:01 -06:00
Derek Collison
00901acc78 Update license to Apache 2 2018-03-15 22:31:07 -07:00
Ivan Kozlovic
9cddf0fcdf [FIXED] Windows Docker Image
The use of the `svc` API prevented the NATS Server to run as
a container on both nanoserver and windowsservercore Docker images.
An attempt was made to replace svc.Debug with normal server.Start()
if detected to be interactive, however, that did not work. The
fact of detecting if interactive or not already requires connecting
to the service controller apparently.
This change looks up for an environment variable (NATS_DOCKERIZED)
and if set to "1", will not make use of the `svc` package.
This environment variable will be set in the Docker image (in
nats-docker/windows/nanoserver/Dockerfile and windowsservercore/Dockerfile).

Resolves #543
2017-07-18 19:00:17 -06:00
Tyler Treat
54e23a3989 Enable syslog when running as Windows service
This writes logs to the Windows event log.
2017-06-28 14:16:26 -05:00
Tyler Treat
4eea6f1557 Fix custom windows service control code 2017-06-26 17:39:17 -05:00
Tyler Treat
81e94ae4f1 Implement Windows service signalling 2017-06-26 11:41:53 -05:00
Tyler Treat
09550f0f09 Handle run errors 2017-06-23 13:56:32 -05:00
Tyler Treat
6708c6cdfd Implement gnatsd as a Windows service 2017-06-23 11:08:52 -05:00