Skip to content

Instantly share code, notes, and snippets.

@berekuk
Created November 30, 2013 17:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save berekuk/7722172 to your computer and use it in GitHub Desktop.
Save berekuk/7722172 to your computer and use it in GitHub Desktop.
Ubic custom status checks example
# two options:
# 1) put it into Ubic::Service::Starman::WithFileChangeDetection, and reuse it in multiple ubicservice configs;
# in this case, you'll have to add [package ...] line here
# 2) put it directly into service config; in this case, you don't need package line
use strict;
use warnings;
use parent qw(Ubic::Service::Starman); # or whatever you use
use Ubic::Result qw(result);
sub status_impl {
my $self = shift;
my $status = result( $self->SUPER::status_impl() );
return $status if $status->status ne "running";
my $needs_restart = ... # check service files
if ($needs_restart) {
return "broken"; # or, even better: return result("broken", "file $file changed");
}
else {
return $status;
}
}
# 1) if this is a Ubic::... module file, then just return 1 here, as usual
# 2) if this is a service config, then:
# return __PACKAGE__->new({ service options })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment