Permalink
Browse files

start removing of all the mogstored-FOO parallel binaries for the

child processes, moving them into classes with 'run', etc methods.

makes /usr/bin/ cleaner, makes Makefile.PL cleaner, makes stuff easier
to read/find/etc.



git-svn-id: http://code.sixapart.com/svn/mogilefs/trunk@931 f67b2e87-0811-0410-a7e0-dd94e48410d6
  • Loading branch information...
1 parent dde3329 commit 77731666ffcf36aae99c7a31554a7dfa2f2a34bb @bradfitz bradfitz committed May 1, 2007
View
@@ -38,7 +38,6 @@ mogautomount
mogdbsetup
mogilefsd
mogstored
-mogstored-diskusage
mogstored-iostat
t/00-startup.t
t/10-weighting.t
@@ -53,3 +52,5 @@ lib/Mogstored/HTTPServer/Perlbal.pm
lib/Mogstored/SideChannelClient.pm
lib/Mogstored/SideChannelListener.pm
mogstored-fidsizes
+lib/Mogstored/ChildProcess.pm
+lib/Mogstored/ChildProcess/DiskUsage.pm
View
@@ -14,4 +14,4 @@ _blib$
\bdebian\b
\bconf\b
\.svn
-
+dev-killmogstored.sh
View
@@ -11,8 +11,8 @@
use ExtUtils::MakeMaker;
-my $exefiles = ["mogstored", "mogstored-iostat", "mogstored-diskusage", "mogilefsd", "mogdbsetup", "mogautomount"];
-$exefiles = ["mogstored", "mogstored-iostat", "mogstored-diskusage"] if exists $ENV{DANGABUILD_MOGSTOREDONLY};
+my $exefiles = ["mogstored", "mogstored-iostat", "mogilefsd", "mogdbsetup", "mogautomount"];
+$exefiles = ["mogstored", "mogstored-iostat"] if exists $ENV{DANGABUILD_MOGSTOREDONLY};
$exefiles = ["mogilefsd"] if exists $ENV{DANGABUILD_MOGILEFSDONLY};
WriteMakefile(
View
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+ps afx | grep mogstore | perl -npe 's/\spts.+//' | xargs kill
View
@@ -6,6 +6,7 @@
die "not sure where we're at";
$ENV{PERL5LIB} = join(":",
+ "$svn/mogilefs/server/lib",
"$svn/perlbal/lib",
"$svn/gearman/api/perl/Gearman/lib",
"$svn/gearman/api/perl/Gearman-Client-Async/lib",
@@ -0,0 +1,19 @@
+package Mogstored::ChildProcess;
+use strict;
+
+sub run {
+ my $class = shift;
+ die "run not implemented for $class\n";
+}
+
+sub pre_exec_init {
+ my $class = shift;
+ # override to setup environment ...
+}
+
+sub exec {
+ my $class = shift;
+ exec $^X, "-M$class", "-e", "$class->run;";
+}
+
+1;
@@ -1,20 +1,28 @@
-#!/usr/bin/perl
+package Mogstored::ChildProcess::DiskUsage;
use strict;
+use base 'Mogstored::ChildProcess';
-# this is the diskusage subprocess for mogstored. see 'mogstored' for copyright & licensing info.
-# (C) 2007 Six Apart, Ltd.
+my $docroot;
-my $docroot = $ENV{MOG_DOCROOT};
-die "\$ENV{MOG_DOCROOT} not set" unless $docroot;
-die "\$ENV{MOG_DOCROOT} not set to a directory" unless -d $docroot;
+sub pre_exec_init {
+ my $class = shift;
+ $SIG{TERM} = 'DEFAULT'; # override custom one from earlier
+ $ENV{MOG_DOCROOT} = Perlbal->service('mogstored')->{docroot};
+}
+
+sub run {
+ $docroot = $ENV{MOG_DOCROOT};
+ die "\$ENV{MOG_DOCROOT} not set" unless $docroot;
+ die "\$ENV{MOG_DOCROOT} not set to a directory" unless -d $docroot;
-# (runs in exec'd child process)
-$0 = "mogstored [diskusage]";
-select((select(STDOUT), $|++)[0]);
+ # (runs in exec'd child process)
+ $0 = "mogstored [diskusage]";
+ select((select(STDOUT), $|++)[0]);
-while (1) {
- look_at_disk_usage();
- sleep 10;
+ while (1) {
+ look_at_disk_usage();
+ sleep 10;
+ }
}
sub look_at_disk_usage {
@@ -68,3 +76,5 @@ sub look_at_disk_usage {
}
}
+
+1;
View
@@ -207,13 +207,10 @@ sub start_disk_usage_process {
return $child;
}
- $SIG{TERM} = 'DEFAULT'; # override custom one from earlier
-
- $ENV{MOG_DOCROOT} = Perlbal->service('mogstored')->{docroot};
-
- my $exe = $selfexe;
- $exe =~ s/mogstored$/mogstored-diskusage/ or die "$0 not what we were expecting!";
- exec $exe;
+ require Mogstored::ChildProcess::DiskUsage;
+ my $class = "Mogstored::ChildProcess::DiskUsage";
+ $class->pre_exec_init;
+ $class->exec;
}
sub Mogstored::iostat_subscribe {

0 comments on commit 7773166

Please sign in to comment.