Skip to content

Commit

Permalink
Strip out all Mysql service controls from the WRE.
Browse files Browse the repository at this point in the history
  • Loading branch information
perlDreamer committed Jan 7, 2012
1 parent 7ea6018 commit 9bfd3ac
Show file tree
Hide file tree
Showing 8 changed files with 0 additions and 177 deletions.
12 changes: 0 additions & 12 deletions wre/etc/wre.conf
Expand Up @@ -5,18 +5,6 @@
"domainRoot" : "/data/domains",
"user" : "webgui",

# mysql
"mysql" : {
"hostname" : "localhost",
"adminUser" : "root",
"test" : {
"database" : "test",
"user" : "test",
"password" : "test"
},
"port" : 3306
},

# starman
"starman" : {
"maxMemory" : 100000000,
Expand Down
80 changes: 0 additions & 80 deletions wre/lib/WRE/Mysql.pm
Expand Up @@ -173,86 +173,6 @@ sub load {
system($command);
}


#-------------------------------------------------------------------

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

sub ping {
my $self = shift;
my $config = $self->wreConfig;
my $db;
eval {$db = $self->getDatabaseHandle(password=>$config->get("mysql/test/password"), username=>$config->get("mysql/test/user"))};
if (defined $db) {
$db->disconnect;
return 1;
}
return 0;
}

#-------------------------------------------------------------------

=head2 start ( )
Returns a 1 if the start was successful, or a 0 if it was not.
Note: The process that runs this command must be either root or the user specified in the WRE config file.
=cut

sub start {
my $self = shift;
my $count = 0;
my $success = 0;
my $config = $self->wreConfig;
my $cmd = "service mysql start";
`$cmd`; # catch command line output
while ($count < 10 && $success == 0) {
sleep(1);
eval {$success = $self->ping };
$count++;
}
if ($success) {
$config->set("wreMonitor/mysqlAdministrativelyDown", 0);
}
return $success;
}

#-------------------------------------------------------------------

=head2 stop ( )
Returns a 1 if the stop was successful, or a 0 if it was not.
Note: The process that runs this command must be either root or the user specified in the WRE config file.
=cut

sub stop {
my $self = shift;
my $count = 0;
my $success = 1;
my $config = $self->wreConfig;
my $cmd = "service mysql stop";
`$cmd`; # catch command line output
while ($count < 10 && $success == 1) {
sleep(1);
eval {$success = $self->ping };
$count++;
}
if (!$success) {
$config->set("wreMonitor/mysqlAdministrativelyDown", 1);
}
return !$success;
}




} # end inside out object

1;
14 changes: 0 additions & 14 deletions wre/lib/WRE/Site.pm
Expand Up @@ -145,16 +145,9 @@ displayed to a user.
sub checkCreationSanity {
my $self = shift;
my $wreConfig = $self->wreConfig;
my $mysql = WRE::Mysql->new(wreConfig=>$wreConfig);
my $sitename = $self->sitename;
my $password = $adminPassword{id $self};

# check that mysql is alive
unless (eval {$mysql->ping}) {
croak "MySQL appears to be down. ".$@;
return 0;
}

# check that this user has admin rights
unless (eval {$mysql->isAdmin(password=>$password)}) {
croak "Invalid admin password. ". $@;
Expand Down Expand Up @@ -200,16 +193,9 @@ displayed to a user.
sub checkDeletionSanity {
my $self = shift;
my $wreConfig = $self->wreConfig;
my $mysql = WRE::Mysql->new(wreConfig=>$wreConfig);
my $sitename = $self->sitename;
my $filename = $sitename.".conf";

# check that mysql is alive
unless (eval {$mysql->ping}) {
croak "MySQL appears to be down. ".$@;
return 0;
}

# check that this user has admin rights
unless (eval {$mysql->isAdmin(password=>$adminPassword{id $self})} ) {
croak "Invalid admin password.";
Expand Down
14 changes: 0 additions & 14 deletions wre/sbin/services/freebsd/webgui
Expand Up @@ -10,7 +10,6 @@ rcvar=`set_rcvar`
extra_commands="help startweb stopweb restartweb\
startstarman stopstarman restartstarman\
startnginx stopnginx restartnginx\
startmysql stopmysql restartmysql\
startspectre stopspectre restartspectre\
"
help_cmd="${name}_help"
Expand All @@ -25,9 +24,6 @@ restartnginx_cmd="${stopnginx_cmd}; ${startnginx_cmd}"
startstarman_cmd="${name}_startstarman"
stopstarman_cmd="${name}_stopstarman"
restartstarman_cmd="${stopstarman_cmd}; ${startstarman_cmd}"
startmysql_cmd="${name}_startmysql"
stopmysql_cmd="${name}_stopmysql"
restartmysql_cmd="${stopmysql_cmd}; ${startmysql_cmd}"
startspectre_cmd="${name}_startspectre"
stopspectre_cmd="${name}_stopspectre"
restartspectre_cmd="${stopspectre_cmd}; ${startspectre_cmd}"
Expand All @@ -45,8 +41,6 @@ webgui_help() {
echo " -- Start/stop mod_perl (WebGUI) Apache service"
echo " $0 { startnginx | stopnginx | restartnginx }"
echo " -- Start/stop mod_proxy Apache service"
echo " $0 { startmysql | stopmysql | restartmysql }"
echo " -- Start/stop MySQL service"
echo " $0 { startspectre | stopspectre | restartspectre }"
echo " -- Start/stop SPECTRE"
exit 1
Expand Down Expand Up @@ -76,14 +70,6 @@ webgui_stopnginx() {
wreservice.pl --quiet --stop nginx
}

webgui_startmysql() {
wreservice.pl --quiet --start mysql
}

webgui_stopmysql() {
wreservice.pl --quiet --stop mysql
}

webgui_startspectre() {
wreservice.pl --quiet --start spectre
}
Expand Down
10 changes: 0 additions & 10 deletions wre/sbin/services/redhat/webgui
Expand Up @@ -16,15 +16,6 @@ case "$1" in
restart)
/data/wre/sbin/wreservice.pl --quiet --restart all
;;
startmysql)
/data/wre/sbin/wreservice.pl --quiet --start mysql
;;
stopmysql)
/data/wre/sbin/wreservice.pl --quiet --stop mysql
;;
restartmysql)
/data/wre/sbin/wreservice.pl --quiet --restart mysql
;;
startweb)
/data/wre/sbin/wreservice.pl --quiet --start web
;;
Expand Down Expand Up @@ -68,7 +59,6 @@ case "$1" in
echo $" $0 { startweb | stopweb | restartweb }"
echo $" $0 { startstarman | stopstarman | restartstarman }"
echo $" $0 { startnginx | stopnginx | restartnginx }"
echo $" $0 { startmysql | stopmysql | restartmysql }"
echo $" $0 { startspectre | stopspectre | restartspectre }"
exit 1
esac
Expand Down
26 changes: 0 additions & 26 deletions wre/sbin/services/redhat/wre-mysql

This file was deleted.

6 changes: 0 additions & 6 deletions wre/sbin/wremonitor.pl
Expand Up @@ -21,7 +21,6 @@
use WRE::File;
use WRE::Starman;
use WRE::Nginx;
use WRE::Mysql;
use WRE::Spectre;

# don't want two copies of this to run simultaneously
Expand All @@ -33,11 +32,6 @@

my $config = WRE::Config->new;

if ($config->get("wreMonitor/items/mysql") && !$config->get("wreMonitor/mysqlAdministrativelyDown")) {
my $mysql = WRE::Mysql->new(wreConfig=>$config);
monitor($mysql);
}

if ($config->get("wreMonitor/items/starman") && !$config->get("wreMonitor/starmanAdministrativelyDown")) {
my $starman = WRE::Starman->new(wreConfig=>$config);
monitor($starman);
Expand Down
15 changes: 0 additions & 15 deletions wre/sbin/wreservice.pl
Expand Up @@ -17,7 +17,6 @@
use WRE::Host;
use WRE::Starman;
use WRE::Nginx;
use WRE::Mysql;
use WRE::Spectre;

$|=1; # turn off buffering
Expand Down Expand Up @@ -48,8 +47,6 @@
nginx The nginx service which provides performance and security
services for WebGUI.
mysql WebGUI's database engine.
spectre WebGUI's workflow governor.
web A shortcut that represents both starman and nginx.
Expand Down Expand Up @@ -101,15 +98,9 @@
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");
}
}

if (scalar(@start)) {
if (grep /^mysql|all$/, @start) {
printSuccess(sub{WRE::Mysql->new(wreConfig=>$config)->start}, "Start MySQL");
}
if (grep /^starman|modperl|all|web$/, @start) {
printSuccess(sub{WRE::Starman->new(wreConfig=>$config)->start}, "Start starman");
}
Expand All @@ -122,9 +113,6 @@
}

if (scalar(@restart)) {
if (grep /^mysql|all$/, @restart) {
printSuccess(sub{WRE::Mysql->new(wreConfig=>$config)->restart}, "Restart MySQL");
}
if (grep /^starman|modperl|all|web$/, @restart) {
printSuccess(sub{WRE::Starman->new(wreConfig=>$config)->restart}, "Restart starman");
}
Expand All @@ -137,9 +125,6 @@
}

if (scalar(@status)) {
if (grep /^mysql|all$/, @status) {
printSuccess(sub{WRE::Mysql->new(wreConfig=>$config)->ping}, "Ping MySQL");
}
if (grep /^starman|modperl|all|web$/, @status) {
printSuccess(sub{WRE::Starman->new(wreConfig=>$config)->ping}, "Ping starman");
}
Expand Down

0 comments on commit 9bfd3ac

Please sign in to comment.