Coder Social home page Coder Social logo

Make PARSEC a daemon about parsec HOT 5 CLOSED

parallaxsecond avatar parallaxsecond commented on July 17, 2024
Make PARSEC a daemon

from parsec.

Comments (5)

hug-dev avatar hug-dev commented on July 17, 2024 1

Agree to both points.
I have written some research I made about the subject and what I think we should be doing:

There seems to be two kinds of daemons:

  • "traditional" SysV daemons which contain a double-forking mechanism to separate themselves from their parent process and the TTY they are linked to. They redirect themselves their standard file descriptors to a file or system wide logging. The crate daemonize works like that.
  • "modern" systemd daemons where systemd itself manages the daemons which do not have to do anything special apart from having a graceful shutdown mechanism. This can be done by implementing a SIGTERM signal handler (signal that is sent to the daemon when systemd wants to close it.) systemd needs a service file that describe the service type and its logging mechanism. Logs can be redirected easily so that they can be viewed with the journalctl, something like journalctl -u parsecd.service. There are also advanced features of systemd to automatically start-up the daemon whenever a connection is received on the socket, and not have it running all the time.

I am mostly inclined to follow the modern, systemd, process of daemonization and I see for that the following tasks:

  1. Create a .service file and put it at the root of this repo (same way as containerd does)
  2. Implement a handler of the SIGTERM signal to cleanly shutdown PARSEC (send to all thread a message through a channel for them to return and join them)
  3. Adds CI tests where PARSEC is run as a daemon, with systemctl commands.

Separate but linked tasks:

  • With #36, replace all println calls with a real logging system (log + env_logger for example). (Possibly add log tests?)
  • Investigate socket activation of PARSEC

Note: systemd is a Linux only daemon manager, which is not on MacOS. The service will need to have OS dependant (#[cfg]?) code and still work by just running cargo run on other OSes. We will need to investigate daemon manager on the other OSes we want PARSEC to run on.

Ressources: simple description, daemon man page, types of services, Go example

from parsec.

justincormack avatar justincormack commented on July 17, 2024

logging to stdout is the normal way for daemons to run now; systemd or whatever will handle redirecting logs to wherever, so it is not necessary to change that. We should have a clean shutdown.

from parsec.

ionut-arm avatar ionut-arm commented on July 17, 2024

The points above seem good, but I have a few questions/points:

  • Log tests are probably overkill. Manual checking should suffice
  • Given the architecture of PARSEC, how will the socket activation fit into it? I agree that it's a nifty tool, but only as long as it doesn't open us up to someone tricking the system
  • We should future-proof at least a tiny bit, in case we need to make PARSEC a Windows service too :)

from parsec.

hug-dev avatar hug-dev commented on July 17, 2024

Agree to all points.
I think socket activation is an advanced topic that will need more look into once a basic service is working. Will look into simple and notify services at first, with no socket activation (the service will initialise its own socket). Socket activation will also be socket dependant and I don't know how it would interact if we have other kinds of listeners.
I will make sure that the normal behaviour cargo run, still works on other OS.

from parsec.

hug-dev avatar hug-dev commented on July 17, 2024

CC @paulhowardarm for your information

from parsec.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.