Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not set a default value for state directory #48

Merged
merged 2 commits into from Mar 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -14,7 +14,7 @@
<parent>
<groupId>org.quattor.maven</groupId>
<artifactId>build-profile</artifactId>
<version>1.51</version>
<version>1.52</version>
</parent>
<scm>
<connection>scm:git:git://github.com/quattor/ncm-cdispd.git</connection>
Expand Down
4 changes: 2 additions & 2 deletions src/main/config/ncm-cdispd.conf
Expand Up @@ -24,7 +24,7 @@
# ncd-retries =

# time in seconds between retries
# ncd-timeout =
# ncd-timeout =

# profile to use as configuration profile
# ncd-useprofile =
Expand All @@ -36,4 +36,4 @@
# noaction =

# Where to keep state information
state = /var/run/quattor-components
# state =
23 changes: 8 additions & 15 deletions src/main/perl/Application.pm
@@ -1,12 +1,4 @@
# ${license-info}
# ${developer-info}
# ${author-info}
# ${build-info}

package CDISPD::Application;

use strict;
use warnings;
#${PMpre} CDISPD::Application${PMpost}

=pod

Expand All @@ -21,15 +13,14 @@ This class provides the ncm-cdispd specific methods used to initialize the CAF::
=cut


use Exporter;

use CAF::Application;
use CAF::Reporter 16.8.1;
use CAF::Process;
use CAF::Object;
use LC::Exception qw (SUCCESS throw_error);

our @ISA = qw(CAF::Application CAF::Reporter Exporter);
use parent qw(CAF::Application CAF::Reporter Exporter);

our @EXPORT = qw(CDISPD_CONFIG_FILE);

use constant CDISPD_CONFIG_FILE => "/etc/ncm-cdispd.conf";
Expand All @@ -38,7 +29,8 @@ use constant CDISPD_CONFIG_FILE => "/etc/ncm-cdispd.conf";
# Public Methods/Functions for CAF
#

sub app_options {
sub app_options
{

my $self = shift;

Expand Down Expand Up @@ -149,7 +141,8 @@ sub app_options {

}

sub _initialize {
sub _initialize
{

my $self = shift;

Expand Down Expand Up @@ -177,7 +170,7 @@ sub _initialize {
# start initialization of CAF::Application
#
unless ( $self->SUPER::_initialize(@_) ) {
return undef;
return;
}

# start using log file
Expand Down
4 changes: 2 additions & 2 deletions src/main/perl/Utils.pm
Expand Up @@ -22,8 +22,8 @@ which components must be run.
####################################################################

use POSIX qw(setsid);
require Exporter;
our @ISA = qw(Exporter);

use parent qw(Exporter);

use CAF::Object qw (SUCCESS throw_error);
use EDG::WP4::CCM::CacheManager;
Expand Down
36 changes: 19 additions & 17 deletions src/main/scripts/ncm-cdispd
Expand Up @@ -209,11 +209,6 @@ one has exited, at the end of `ncm-ncd`.

=cut

BEGIN {
# use perl libs in /usr/lib/perl
unshift( @INC, '/usr/lib/perl' );
}


#############################################################
# cdispd program and its functions
Expand All @@ -225,10 +220,14 @@ BEGIN {
# (very verbose!)
#############################################################

package main;

use strict;
use warnings;

BEGIN {
# use perl libs in /usr/lib/perl
unshift( @INC, '/usr/lib/perl' );
}

use POSIX qw(setsid);

use CAF::Object qw ( throw_error);
Expand Down Expand Up @@ -295,7 +294,8 @@ No return value.

=cut

sub register_signal {
sub register_signal
{

my $signal = shift;
unless ( $signal ) {
Expand Down Expand Up @@ -369,7 +369,8 @@ Proccess HUP signal: reinitialize cdispd daemon

=cut

sub signal_reinitialize {
sub signal_reinitialize
{

my $signal = shift;
unless ( $signal ) {
Expand Down Expand Up @@ -439,17 +440,17 @@ sub daemonize
exit(-1);
}

if ( !open( STDIN, '/dev/null' ) ) {
if ( !open(STDIN, '<', '/dev/null') ) {
$this_app->error("Can't read /dev/null: $! : Exiting");
exit(-1);
}

if ( !open( STDOUT, ">> $logfile" ) ) {
if ( !open(STDOUT, ">>", $logfile) ) {
$this_app->error("Can't write to $logfile: $! : Exiting");
exit(-1);
}

if ( !open( STDERR, ">> $logfile" ) ) {
if ( !open(STDERR, ">>", $logfile ) ) {
$this_app->error("Can't write to $logfile: $! : Exiting");
exit(-1);
}
Expand All @@ -463,13 +464,14 @@ sub daemonize

# Save the PID.
if ( $this_app->option('pidfile') ) {
if ( !open( PIDFILE, ">" . $this_app->option('pidfile') ) ) {
if ( !open(my $PIDFILE, ">", $this_app->option('pidfile') ) ) {
$this_app->error( "Cannot write PID to file \""
. $this_app->option('pidfile')
. "\": $! : Exiting" );
exit(-1);
}
print( PIDFILE "$$" );
print $PIDFILE "$$";
close $PIDFILE;
}

if ( $this_app->option('state') ) {
Expand Down Expand Up @@ -549,7 +551,7 @@ sub launch_ncd
my $result = 0; # Assume success

my $p = CAF::Process->new([NCD_EXECUTABLE, '--configure'] , log => $this_app );
if ( defined( $this_app->{ICLIST} ) && scalar(@{$this_app->{ICLIST}}) ) {
if ( defined( $this_app->{ICLIST} ) && scalar(@{$this_app->{ICLIST}}) ) {
# At this point, ICLIST should contain only components present in the last profile received.
# The only case where a component may be in the list without being part of the configuration
# is the following:
Expand Down Expand Up @@ -588,11 +590,11 @@ sub launch_ncd
delay_signals();

# Execute ncm-ncd and report exit status
sub act {
my $act = sub {
my ($logger, $message) = @_;
$logger->verbose($message);
}
my $errormsg = $p->stream_output(\&act, mode => 'line', arguments => [$this_app]);
my $errormsg = $p->stream_output($act, mode => 'line', arguments => [$this_app]);

my $ec = $?;
my $msg = "ncm-ncd finished with status: ". ($ec >> 8) . " (ec $ec";
Expand Down
21 changes: 0 additions & 21 deletions src/test/perl/00-load.t

This file was deleted.

11 changes: 11 additions & 0 deletions src/test/perl/00-tqu.t
@@ -0,0 +1,11 @@
BEGIN {
our $TQU = <<'EOF';
[load]
prefix=CDISPD::
modules=Application,Utils
[doc]
poddirs=target/lib/perl,target/sbin
panpaths=NOPAN
EOF
}
use Test::Quattor::Unittest;
6 changes: 0 additions & 6 deletions src/test/perl/pod-syntax.t

This file was deleted.