I am in reference to the Twelve-Factor app "manifesto" which can be found here: http://12factor.net
In the eighth factor, the author writes:
Twelve-factor app processes should never daemonize or write PID files. Instead, rely on the operating system’s process manager (such as Upstart, a distributed process manager on a cloud platform, or a tool like Foreman in development) to manage output streams, respond to crashed processes, and handle user-initiated restarts and shutdowns.
I am not sure what is meant here by "processes should never daemonize".
Can someone please explain what the pros and cons of daemonizing a process would be - especially in the context of a java process? Also, can't a daemonized process be managed by a process manager?
The 12 Factor App is a set of principles that describes a way of making software that, when followed, enables companies to create code that can be released reliably, scaled quickly, and maintained in a consistent and predictable manner.
There is always a one-to-one correlation between the codebase and the app: If there are multiple codebases, it's not an app – it's a distributed system. Each component in a distributed system is an app, and each can individually comply with twelve-factor.
The twelve-factor app treats these databases as attached resources, which indicates their loose coupling to the deploy they are attached to. Resources can be attached to and detached from deploys at will.
If a process deamonizes, it means it is effectively trying to manage its lifecycle by itself. This is good for certain applications types, but for the distributed web application, and this is the kind of app the 12-factor manifesto pertains to, it will usually mean trouble. If an app tries to manage itself, it will probably not be easily managed by external process managers or in best case it may mean that custom plugins or extensions to these managers are needed, which complicates deployment.
An example of what you would want to do to an app and what daemonization could prevent would be automatic scaling. With tools such as Mesos, you essentially want to tell the system: “here are my 50 machines, now put my apps on these machines”. You don't wan't to manually manage what goes where but let the cluster manager handle it automatically. It might set up more or fewer instances automatically depending on conditions, e.g. how much traffic your system is receiving, and it could put several instances on a single machine. If an app tries to manage itself, it will interfere and make such external management impossible or very complex.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With