From: kupcevic@sourceware.org <kupcevic@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] conga/ricci/modules/service ServiceManager.cpp ...
Date: 24 Feb 2007 09:39:23 -0000 [thread overview]
Message-ID: <20070224093923.9723.qmail@sourceware.org> (raw)
CVSROOT: /cvs/cluster
Module name: conga
Changes by: kupcevic at sourceware.org 2007-02-24 09:39:23
Modified files:
ricci/modules/service: ServiceManager.cpp ServiceManager.h
Log message:
- restart set in proper order
- localize internal enum
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/service/ServiceManager.cpp.diff?cvsroot=cluster&r1=1.10&r2=1.11
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/service/ServiceManager.h.diff?cvsroot=cluster&r1=1.3&r2=1.4
--- conga/ricci/modules/service/ServiceManager.cpp 2007/02/23 22:02:57 1.10
+++ conga/ricci/modules/service/ServiceManager.cpp 2007/02/24 09:39:22 1.11
@@ -172,7 +172,7 @@
Service::start()
{
running();
- run_service(name(), SERVICE_START);
+ run_service(name(), START);
*_running = true;
}
@@ -180,7 +180,7 @@
Service::restart()
{
running();
- run_service(name(), SERVICE_RESTART);
+ run_service(name(), RESTART);
*_running = true;
}
@@ -188,7 +188,7 @@
Service::stop()
{
running();
- run_service(name(), SERVICE_STOP);
+ run_service(name(), STOP);
*_running = false;
}
@@ -225,7 +225,7 @@
}
void
-Service::run_service(const String& name, int state)
+Service::run_service(const String& name, ActionState state)
{
String path(INITD_DIR_PATH);
path += name;
@@ -233,22 +233,27 @@
String out, err;
int status;
vector<String> args;
- if (state == SERVICE_START)
- args.push_back("start");
- else if (state == SERVICE_RESTART)
- args.push_back("restart");
- else if (state == SERVICE_STOP)
- args.push_back("stop");
+ switch (state) {
+ case START:
+ args.push_back("start");
+ break;
+ case STOP:
+ args.push_back("stop");
+ break;
+ case RESTART:
+ args.push_back("restart");
+ break;
+ }
if (utils::execute(path, args, out, err, status, false) != 0)
throw command_not_found_error_msg(path);
if (status) {
- bool running = service_running(name);
- if (state == SERVICE_START || state == SERVICE_RESTART) {
- if (!running)
- throw String("service ") + name + " " + String(state == SERVICE_START ? "start" : "restart") + " failed";
+ bool running = service_running(name);
+ if (state == START || state == RESTART) {
+ if (!running)
+ throw String("service ") + name + " " + String(state == START ? "start" : "restart") + " failed";
} else {
- if (running)
- throw String("service ") + name + " " + String("stop") + " failed";
+ if (running)
+ throw String("service ") + name + " stop failed";
}
}
}
@@ -377,10 +382,9 @@
{
name();
try {
- for (list<Service>::iterator iter = servs.begin();
- iter != servs.end();
- iter++)
- iter->restart();
+ // ordered sequence: last started, first to be stoped
+ stop();
+ start();
} catch (String e) {
throw String("service set '") + name() + "' failed to restart";
}
--- conga/ricci/modules/service/ServiceManager.h 2007/02/23 22:02:57 1.3
+++ conga/ricci/modules/service/ServiceManager.h 2007/02/24 09:39:22 1.4
@@ -34,11 +34,6 @@
class ServiceManager;
-enum {
- SERVICE_STOP,
- SERVICE_START,
- SERVICE_RESTART
-};
class Service
{
@@ -67,9 +62,15 @@
mutable counting_auto_ptr<bool> _enabled;
mutable counting_auto_ptr<bool> _running;
+ enum ActionState {
+ START,
+ STOP,
+ RESTART
+ };
+
static void enable_service(const String& name, bool on);
static bool service_running(const String& name);
- static void run_service(const String& name, int state);
+ static void run_service(const String& name, ActionState state);
friend class ServiceManager;
next reply other threads:[~2007-02-24 9:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-24 9:39 kupcevic [this message]
-- strict thread matches above, loose matches on Subject: below --
2007-09-11 13:53 [Cluster-devel] conga/ricci/modules/service ServiceManager.cpp rmccabe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070224093923.9723.qmail@sourceware.org \
--to=kupcevic@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.