Skip to content

Instantly share code, notes, and snippets.

@berekuk
Created May 24, 2012 15:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save berekuk/b7a2ab5ae45df5847682 to your computer and use it in GitHub Desktop.
Save berekuk/b7a2ab5ae45df5847682 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use warnings;
use Ubic::Service::SimpleDaemon;
use Ubic::InitScript;
Ubic::InitScript->run(
Ubic::Service::SimpleDaemon->new(
bin => 'sleep 1000',
pid => '/tmp/blah.pid',
stdout => ...,
)
);
# We can replace "Ubic" with some other word, to make separation clearer.
# Like Plack vs PSGI.
# Then we can refactor Daemon::Control to two parts: service class and init script runner.
# Or maybe we will replace it with Ubic::Service::SimpleDaemon completely or merge their code :)

So, there's Ubic::Daemon, it's a pure daemonization module like Proc::Daemon.

Good things about it:

  1. cross-platform features (Win32 not implemented yet, but foundation is there)
  2. we debugged tons of bugs in it
  3. it doesn't require /etc/ubic/service/ at all

Bad things:

  1. ubic-guardian is required and can be annoying, but read https://metacpan.org/module/Ubic::Manual::FAQ#What-is-this-ubic-guardian-process-I-see-in-my-ps-aux-output-.

Then there is Ubic::Service base class and Ubic::Service::* modules. They are polymorhic and extensible and can be customized for different daemons and different local policies. This is a good thing. We want to reuse them in pure init script environment. Service modules tied to /etc/ubic/service/ and other ubic machinery via ->name, ->full_name and ->parent_name methods (there is no Mo*, but they're like rw accessors). Ubic::Service::SimpleDaemon and some other services depend on service name, so that pidfile can be generated based on it. It won't be hard to refactor most of them and make service name optional.

Then there is ubic service tree and Ubic.pm frontend and /usr/bin/ubic script. We want to make them all optional.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment