Created
November 30, 2013 17:53
-
-
Save berekuk/7722172 to your computer and use it in GitHub Desktop.
Ubic custom status checks example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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