ubic-guardian and ubic-update

40 views
Skip to first unread message

bessarabov

unread,
Aug 23, 2010, 5:31:03 AM8/23/10
to Ubic
As I know there is a script called ubic-watchdog that runs under cron.
It knows what services should be up and if they are down ubic-wathcdog
starts them.

If I run "ps aux|grep ubic" on machine running ubic I will see several
process of ubic-guardian. I'm a bit confused with it's purpose. From
it's name one can thing that it should work just like watchdog, but
I'm not sure that this is right. My first question is what is the
purpose of ubic-guardian.

After installing ubic from deb file, 2 things are placed in cron: ubic-
watchdog and ubic-update. There is a short description about second
one in "man ubic-update", but I still don't understand what it does
and why does it need to be run every minute. This is my second
question.

By the way, there is a small misspell in "man ubic-update". In
SYNOPSIS section the script is called ubic-date. =)

Thanks in advance for the answers!

Вячеслав Матюхин

unread,
Aug 23, 2010, 11:59:45 AM8/23/10
to ubic...@googlegroups.com
On Aug 23, 2010, at 13:31, bessarabov wrote:

As I know there is a script called ubic-watchdog that runs under cron.
It knows what services should be up and if they are down ubic-wathcdog
starts them.

If I run "ps aux|grep ubic" on machine running ubic I will see several
process of ubic-guardian. I'm a bit confused with it's purpose. From
it's name one can thing that it should work just like watchdog, but
I'm not sure that this is right. My first question is what is the
purpose of ubic-guardian.

At early stages of ubic development, there was an idea that usual pidfiles are unsafe: presence of pidfile doesn't guarantee that process is still alive, and presence of process with pid from pidfile in ps doesn't guarantee it either.

So we thought about daemons which hold lock on pifile for a whole lifetime. This way Linux kernel does the job for us and we can be sure that locked pifile == process is alive.
Since ubic is all about separation of programs and damonizing/watchdog/metadata, we needed external process to hold that lock. Hence, ubic-guardian.
(BTW, ubic-guardian is not a separate script. It is just a part of Ubic::Daemon code which replaces $0.)

Later, Ubic::Daemon learned to compare process start timestamp. Timestamp and pid together are enough to identify process, so lock is now unnecessary.
I think I'll get rid from ubic-guardian process in future releases (transparently from Ubic::Daemon point of view, of course so you shouldn't worry about compatibility).

Maybe the best solution would be to provide alternative Ubic::Service::* modules which would use Net::Daemon::Daemonize, Daemon::Daemonize, MooseX::Daemonize or other daemonization modules from CPAN.
Ubic::Daemon works and definitely mature enough for production, but it's Linux-specific (but you can always ignore Ubic::Daemon and describe your own service using Ubic::Service::Common, of course).


After installing ubic from deb file, 2 things are placed in cron: ubic-
watchdog and ubic-update. There is a short description about second
one in "man ubic-update", but I still don't understand what it does
and why does it need to be run every minute. This is my second
question.

ubic-update updates portmap - local { port => service-name } mapping.
It makes possible to check service status via ubic-ping using its port instead of name:
ok

Resolving of service by port can't be done on-the-fly by ubic-ping, because all service definitions are cached internally by Ubic.pm (Ubic::Multiservice, actually, but you don't have to know the difference), since constant reloading of service definition can cause memory leaks.
So ubic-ping instead just loads portmap generated by ubic-update, resolves service name by port, and loads cached service status from another local file.

In other words, if you don't use ubic-ping, you can disable ubic-update and stop ubic-ping service.


By the way, there is a small misspell in "man ubic-update". In
SYNOPSIS section the script is called ubic-date. =)

Thanks, fixed in repo.


Thanks in advance for the answers!

I copied your questions and my answers to Ubic::Manual::FAQ, BTW.
It's on 'documentation' branch on github. Feel free to add more if you like :)

-- 
Вячеслав Матюхин

Reply all
Reply to author
Forward
0 new messages