ACK to both, with a couple of comments:
* could you replace the tabs w/ 2 spaces each
* this script should go in sbin as it needs to be run by the sysadmin
Other than that looks good and works, feel free to push away after those
changes.
As a side note, I'm starting to think that we will want to write a high
level 'aeolus' init script through which to wrap all our services
through the sysvinit / systemd interface. Something like how the
'condor' init script wraps all the condor services (eg the scheduler,
gridmanager, collector, etc). These scripts will suffice for the time
being though, good work.
-Mo
On 08/30/2011 10:15 AM, mzatko(a)redhat.com wrote:
From: Maros Zatko<mzatko(a)redhat.com>
---
bin/aeolus-restart-services | 48 +++++++++++++++++++++++++++++++++++++++++++
1 files changed, 48 insertions(+), 0 deletions(-)
create mode 100755 bin/aeolus-restart-services
diff --git a/bin/aeolus-restart-services b/bin/aeolus-restart-services
new file mode 100755
index 0000000..5e9eb73
--- /dev/null
+++ b/bin/aeolus-restart-services
@@ -0,0 +1,48 @@
+#!/usr/bin/ruby
+
+# ordered as in rc.d
+services = %w(mongod messagebus iwhd postgresql httpd qpidd deltacloud-ec2-us-east-1
deltacloud-ec2-us-west-1 deltacloud-mock libvirtd condor aeolus-conductor
conductor-dbomatic imagefactory)
+
+def perform(action, svcs)
+ action = action.to_s
+ svcs.map do |script|
+ puts "\n#{action.capitalize}ing #{script} ..."
+ cmd = "/etc/init.d/#{script} #{action}"
+ out = `#{cmd}`
+ if $?.to_i == 0
+ puts " \e[1;32mSuccess:\e[0m #{out.strip}"
+ else
+ puts " \e[1;31mFAILURE:\e[0m #{out.strip}"
+ end
+ $?.to_i
+ end
+end
+
+perform :stop, services.reverse
+perform :start, services
+
+## Other checks
+commands = [
+ {:name => 'condor_q', :command => 'condor_q'},
+ {:name => 'condor_status', :command => 'condor_status'}
+]
+commands.each do |cmd|
+ puts "\nChecking #{cmd[:name]} ..."
+ cmd = "#{cmd[:command]}"
+ out = `#{cmd}`
+ if $?.to_i == 0
+ puts " \e[1;32mSuccess:\e[0m #{out.strip}"
+ else
+ puts " \e[1;31mFAILURE:\e[0m #{out.strip}"
+ end
+end
+
+if perform(:status, ['mongod']) == [1]
+ lockfile = '/var/lib/mongodb/mongod.lock'
+ if File.exists?(lockfile)
+ puts " \e[1;33mremoving\e[0m leftover #{lockfile}"
+ File.delete(lockfile)
+ perform :restart, %w(mongod iwhd)
+ end
+end
+