Re: What is the best way to run a nim program as daemon?

2019-03-12 Thread cumulonimbus
Wholeheartedly recommend not reinventing the daemon wheel - self-daemonizing programs and self log-rotating problems never do things quite the way one needs. use systemd, if that's what on your system, or (I recommend) a djb-inspired system: daemontools, s6, nosh , etc - they are ultra simple an

Re: What is the best way to run a nim program as daemon?

2019-03-11 Thread treeform
I wrote this nim program to elevate other programs to daemon status (and restart them if they crash): [https://github.com/treeform/guardmons/blob/master/daemon.nim](https://github.com/treeform/guardmons/blob/master/daemon.nim)

Re: What is the best way to run a nim program as daemon?

2019-03-11 Thread mashingan
handle with [setControlCHook](https://nim-lang.org/docs/system.html#setControlCHook%2Cproc%29) proc

Re: What is the best way to run a nim program as daemon?

2019-03-11 Thread mrhdias
Thank you all for the suggestions. Just one more question: How do I catch a "KILL" or "HUP" or user abort signal (CTRL-C)?

Re: What is the best way to run a nim program as daemon?

2019-03-11 Thread federico3
There are different init system and tools to run an application as a daemon without having to increase your application's complexity. Currently a lot of distributions ship systemd by default as it provides features like automated health check and restart and security sandboxing. I wrote a littl

Re: What is the best way to run a nim program as daemon?

2019-03-11 Thread mashingan
I usually make the executable as service using [this reference](https://gist.github.com/bcap/5397674)

Re: What is the best way to run a nim program as daemon?

2019-03-10 Thread lucian
For userland it may be good enough (altough you may want to control the log and pid file from within your Nim application). Some OS distributions may even provide a "deamon" command / tool that run your application in that mode (kind of [http://libslack.org/daemon/manpages/daemon.1.html](http:/

What is the best way to run a nim program as daemon?

2019-03-10 Thread mrhdias
This work: $ ./server -p 8080 &> ./logs/server.log & echo $! > ./server.pid; But is this the correct approach?