Skip to content
Permalink
Browse files

Modperl => Starman changes.

  • Loading branch information...
perlDreamer committed Jan 5, 2012
1 parent 6d49e1d commit 3ef7123d15098e7dbf408b672ff6f2cca58c455e
Showing with 45 additions and 65 deletions.
  1. +1 −1 wre/lib/WRE/Starman.pm
  2. +2 −2 wre/sbin/backup.pl
  3. +25 −45 wre/sbin/wreconsole.pl
  4. +6 −6 wre/sbin/wremonitor.pl
  5. +11 −11 wre/sbin/wreservice.pl
@@ -70,7 +70,7 @@ sub killRunaways {

=head2 ping ( )
Returns a 1 if Modperl is running, or a 0 if it is not.
Returns a 1 if Starman is running, or a 0 if it is not.
=cut

@@ -46,7 +46,7 @@ sub backupMysql {

# disable wremonitor to prevent false positives
$config->set("wreMonitor/nginxAdministrativelyDown", 1);
$config->set("wreMonitor/modperlAdministrativelyDown", 1);
$config->set("wreMonitor/starmanAdministrativelyDown", 1);


my $mysql = WRE::Mysql->new(wreConfig=>$config);
@@ -74,7 +74,7 @@ sub backupMysql {
$db->disconnect;

# re-enable WRE monitor
$config->set("wreMonitor/modperlAdministrativelyDown", 0);
$config->set("wreMonitor/starmanAdministrativelyDown", 0);
$config->set("wreMonitor/nginxAdministrativelyDown", 0);
}

@@ -25,7 +25,7 @@
use WRE::Config;
use WRE::File;
use WRE::Host;
use WRE::Modperl;
use WRE::Starman;
use WRE::Nginx;
use WRE::Mysql;
use WRE::Site;
@@ -182,7 +182,7 @@ sub www_addSite {
$content .= '
<h1>Add A Site</h1>
<div class="status">'.$status.'</div>
<p>Adding a site requires you to restart modperl, nginx, and Spectre.</p>
<p>Adding a site requires you to restart starman, nginx, and Spectre.</p>
<form action="/addSiteSave" method="post">
<table>
<tr>
@@ -273,7 +273,7 @@ sub www_deleteSite {
<div class="status">'.$status.'</div>
<p>Are you sure you wish to delete this site and all it\'s content and users? This cannot be undone, once you
click on the button below.</p>
<p>Deleting a site requires you to restart modperl, nginx, and Spectre.</p>
<p>Deleting a site requires you to restart starman, nginx, and Spectre.</p>
<form action="/deleteSiteSave" method="post">
<input type="hidden" name="filename" value="'.$cgi->param("filename").'" />
<table>
@@ -386,9 +386,9 @@ sub www_editSettings {
<input type="radio" name="wreMonNginx" value="1" '.(($wreMonitor->{items}{nginx} == 1) ? 'checked="1"' : '').' />Yes
<input type="radio" name="wreMonNginx" value="0" '.(($wreMonitor->{items}{nginx} != 1) ? 'checked="1"' : '').' />No
- nginx<br />
<input type="radio" name="wreMonModperl" value="1" '.(($wreMonitor->{items}{modperl} == 1) ? 'checked="1"' : '').' />Yes
<input type="radio" name="wreMonModperl" value="0" '.(($wreMonitor->{items}{modperl} != 1) ? 'checked="1"' : '').' />No
- modperl<br />
<input type="radio" name="wreMonSstarman" value="1" '.(($wreMonitor->{items}{starman} == 1) ? 'checked="1"' : '').' />Yes
<input type="radio" name="wreMonSstarman" value="0" '.(($wreMonitor->{items}{starman} != 1) ? 'checked="1"' : '').' />No
- starman<br />
<input type="radio" name="wreMonMysql" value="1" '.(($wreMonitor->{items}{mysql} == 1) ? 'checked="1"' : '').' />Yes
<input type="radio" name="wreMonMysql" value="0" '.(($wreMonitor->{items}{mysql} != 1) ? 'checked="1"' : '').' />No
- MySQL<br />
@@ -580,7 +580,7 @@ sub www_editSettingsSave {
$notifyString =~ s/\s+//g;
my @notify = split(",", $notifyString);
$config->set("wreMonitor/notify", \@notify);
$config->set("wreMonitor/items/modperl", $cgi->param("wreMonModperl"));
$config->set("wreMonitor/items/starman", $cgi->param("wreMonStarman"));
$config->set("wreMonitor/items/nginx", $cgi->param("wreMonNginx"));
$config->set("wreMonitor/items/mysql", $cgi->param("wreMonMysql"));
$config->set("wreMonitor/items/runaway", $cgi->param("wreMonRunaway"));
@@ -639,15 +639,12 @@ sub www_editSettingsSave {
$file->makePath($config->getDomainRoot("/demo"));
$file->copy($config->getRoot("/var/setupfiles/demo.nginx"), $config->getRoot("/etc/demo.nginx"),
{ force => 1, templateVars=>{ sitename=>$config->get("demo/hostname") } });
$file->copy($config->getRoot("/var/setupfiles/demo.modperl"), $config->getRoot("/etc/demo.modperl"),
{ force => 1, templateVars=>{ sitename=>$config->get("demo/hostname") } });
$status .= "Demo settings changed. You must restart nginx and modperl for these changes to take effect.<br />";
$status .= "Demo settings changed. You must restart nginx and starman for these changes to take effect.<br />";
}
# have to disable demos
elsif ($config->get("demo/enabled") == 1 && $cgi->param("enableDemo") == 0) {
$file->delete($config->getRoot("/etc/demo.nginx"));
$file->delete($config->getRoot("/etc/demo.modperl"));
$status .= "Demo settings changed. You must restart nginx and modperl for these changes to take effect.<br />";
$status .= "Demo settings changed. You must restart nginx and starman for these changes to take effect.<br />";
}
$config->set("demo/enabled", $cgi->param("enableDemo"));
$config->set("demo/duration", $cgi->param("demoDuration"));
@@ -729,7 +726,7 @@ sub www_editSite {
}
makeHtmlFormSafe($contents);
$content .= '
<p>Making a modification of these files requires a restart of modperl and nginx afterwards, and sometimes also a restart
<p>Making a modification of these files requires a restart of starman and nginx afterwards, and sometimes also a restart
of Spectre after that.</p>
<form action="/editSiteSave" method="post">
<input type="submit" class="saveButton" value="Save" /> <br /><br />
@@ -750,18 +747,6 @@ sub www_editSite {
<textarea name="nginx">'.$$contents.'</textarea><br />
<input type="submit" class="saveButton" value="Save" /> <br /><br />
';
$$contents = '';
eval { $contents = $file->slurp($state->{config}->getRoot("/etc/".$sitename.".modperl")) };
if ($@) {
carp "Couldn't open $sitename.modperl file for editing $@";
$content .= '<div class="status">'.$@.'</div>';
}
makeHtmlFormSafe($contents);
$content .= '
<div><b>'.$sitename.'.modperl</b></div>
<textarea name="modperl">'.$$contents.'</textarea><br />
<input type="submit" class="saveButton" value="Save" /> <br /><br />
';
sendResponse($state, $content);
}

@@ -787,11 +772,6 @@ sub www_editSiteSave {
$status = "Couldn't save $sitename.nginx. $@";
carp $status;
}
eval { $file->spit($state->{config}->getRoot("/etc/".$sitename.".modperl"), $state->{cgi}->param("modperl")) };
if ($@) {
$status = "Couldn't save $sitename.modperl. $@";
carp $status;
}
www_listSites($state, $status);
}

@@ -830,23 +810,23 @@ sub www_listServices {
</td>
</tr>
<tr>
<td>Apache Modperl</td>
<td>Starman</td>
<td>';
my $modperl = WRE::Modperl->new(wreConfig=>$state->{config});
if (eval{$modperl->ping}) {
my $starman = WRE::Starman->new(wreConfig=>$state->{config});
if (eval{$starman->ping}) {
$content .= '
<form action="/stopModperl" method="post">
<form action="/stopStarman" method="post">
<input type="submit" class="deleteButton" value="Stop" onclick="this.value=\'Stopping...\'" />
</form>';
}
else {
$content .= '
<form action="/startModperl" method="post">
<form action="/startStarman" method="post">
<input type="submit" class="saveButton" value="Start" onclick="this.value=\'Starting...\'" />
</form>';
}
$content .= '
<form action="/restartModperl" method="post">
<form action="/restartStarman" method="post">
<input type="submit" value="Restart" onclick="this.value=\'Restarting...\'" />
</form>
</td>
@@ -974,10 +954,10 @@ sub www_listUtilities {
#-------------------------------------------------------------------
sub www_restartModperl {
my $state = shift;
my $service = WRE::Modperl->new(wreConfig=>$state->{config});
my $status = "Modperl restarted.";
my $service = WRE::Starman->new(wreConfig=>$state->{config});
my $status = "Starman restarted.";
unless ($service->restart) {
$status = "Modperl did not restart successfully. ".$@;
$status = "Starman did not restart successfully. ".$@;
}
www_listServices($state, $status);
}
@@ -1345,10 +1325,10 @@ sub www_setup {
#-------------------------------------------------------------------
sub www_startModperl {
my $state = shift;
my $service = WRE::Modperl->new(wreConfig=>$state->{config});
my $status = "Modperl started.";
my $service = WRE::Starman->new(wreConfig=>$state->{config});
my $status = "Starman started.";
unless (eval {$service->start} ) {
$status = "Modperl did not start successfully. ".$@;
$status = "Starman did not start successfully. ".$@;
}
www_listServices($state, $status);
}
@@ -1418,10 +1398,10 @@ sub www_stopConsole {
#-------------------------------------------------------------------
sub www_stopModperl {
my $state = shift;
my $service = WRE::Modperl->new(wreConfig=>$state->{config});
my $status = "Modperl stopped.";
my $service = WRE::Starman->new(wreConfig=>$state->{config});
my $status = "Starman stopped.";
unless ($service->stop) {
$status = "Modperl did not stop successfully. ".$@;
$status = "Starman did not stop successfully. ".$@;
}
www_listServices($state, $status);
}
@@ -19,7 +19,7 @@
use Net::SMTP;
use WRE::Config;
use WRE::File;
use WRE::Modperl;
use WRE::Starman;
use WRE::Nginx;
use WRE::Mysql;
use WRE::Spectre;
@@ -38,12 +38,12 @@
monitor($mysql);
}

if ($config->get("wreMonitor/items/modperl") && !$config->get("wreMonitor/modperlAdministrativelyDown")) {
my $modperl = WRE::Modperl->new(wreConfig=>$config);
monitor($modperl);
if ($config->get("wreMonitor/items/starman") && !$config->get("wreMonitor/starmanAdministrativelyDown")) {
my $starman = WRE::Starman->new(wreConfig=>$config);
monitor($starman);
if ($config->get("wreMonitor/items/runaway")) {
my $killed = $modperl->killRunaways;
logEntry("Killed $killed ".$modperl->getName." processes that were using too much memory.");
my $killed = $starman->killRunaways;
logEntry("Killed $killed ".$starman->getName." processes that were using too much memory.");
}
}

@@ -15,7 +15,7 @@
use Getopt::Long;
use WRE::Config;
use WRE::Host;
use WRE::Modperl;
use WRE::Starman;
use WRE::Nginx;
use WRE::Mysql;
use WRE::Spectre;
@@ -43,7 +43,7 @@
all A shortcut that represents all the services.
modperl The Apache mod_perl service which runs WebGUI.
starman The starman service which runs WebGUI.
nginx The nginx service which provides performance and security
services for WebGUI.
@@ -52,7 +52,7 @@
spectre WebGUI's workflow governor.
web A shortcut that represents both modperl and nginx.
web A shortcut that represents both starman and nginx.
Actions:
@@ -98,8 +98,8 @@
if (grep /^nginx|modproxy|all|web$/, @stop) {
printSuccess(sub{WRE::Nginx->new(wreConfig=>$config)->stop}, "Stop nginx");
}
if (grep /^modperl|all|web$/, @stop) {
printSuccess(sub{WRE::Modperl->new(wreConfig=>$config)->stop}, "Stop mod_perl");
if (grep /^starman|modperl|all|web$/, @stop) {
printSuccess(sub{WRE::Starman->new(wreConfig=>$config)->stop}, "Stop starman");
}
if (grep /^mysql|all$/, @stop) {
printSuccess(sub{WRE::Mysql->new(wreConfig=>$config)->stop}, "Stop MySQL");
@@ -110,8 +110,8 @@
if (grep /^mysql|all$/, @start) {
printSuccess(sub{WRE::Mysql->new(wreConfig=>$config)->start}, "Start MySQL");
}
if (grep /^modperl|all|web$/, @start) {
printSuccess(sub{WRE::Modperl->new(wreConfig=>$config)->start}, "Start mod_perl");
if (grep /^starman|modperl|all|web$/, @start) {
printSuccess(sub{WRE::Starman->new(wreConfig=>$config)->start}, "Start starman");
}
if (grep /^nginx|modproxy|all|web$/, @start) {
printSuccess(sub{WRE::Nginx->new(wreConfig=>$config)->start}, "Start nginx");
@@ -125,8 +125,8 @@
if (grep /^mysql|all$/, @restart) {
printSuccess(sub{WRE::Mysql->new(wreConfig=>$config)->restart}, "Restart MySQL");
}
if (grep /^modperl|all|web$/, @restart) {
printSuccess(sub{WRE::Modperl->new(wreConfig=>$config)->restart}, "Restart mod_perl");
if (grep /^starman|modperl|all|web$/, @restart) {
printSuccess(sub{WRE::Starman->new(wreConfig=>$config)->restart}, "Restart starman");
}
if (grep /^nginx|modproxy|all|web$/, @restart) {
printSuccess(sub{WRE::Nginx->new(wreConfig=>$config)->restart}, "Restart nginx");
@@ -140,8 +140,8 @@
if (grep /^mysql|all$/, @status) {
printSuccess(sub{WRE::Mysql->new(wreConfig=>$config)->ping}, "Ping MySQL");
}
if (grep /^modperl|all|web$/, @status) {
printSuccess(sub{WRE::Modperl->new(wreConfig=>$config)->ping}, "Ping mod_perl");
if (grep /^starman|modperl|all|web$/, @status) {
printSuccess(sub{WRE::Starman->new(wreConfig=>$config)->ping}, "Ping starman");
}
if (grep /^nginx|modproxy|all|web$/, @status) {
printSuccess(sub{WRE::Nginx->new(wreConfig=>$config)->ping}, "Ping nginx");

0 comments on commit 3ef7123

Please sign in to comment.
You can’t perform that action at this time.