Didn't get an exception when I expected one.

9 views
Skip to first unread message

Tim Uckun

unread,
Nov 11, 2009, 7:39:40 PM11/11/09
to autom...@googlegroups.com
I made a mistake in one of my apache files which caused the apache
server to not start. I thought this would cause an exception in the
service_manager but it didn't. Here is the trace. Is this intended
behavior?

Thanks.



** cp /opt/automate/dist///etc/apache2/sites-available/000-default.conf
/etc/apache2/sites-available/000-default.conf
** ln -s /etc/apache2/sites-available/000-default.conf
/etc/apache2/sites-enabled/000-default.conf
** /etc/init.d/apache2 stop
* Stopping web server apache2

* We failed to correctly shutdown
apache, so we're now killing all running apache processes. This is
almost certainly suboptimal, so please make sure your system is
working as you'd expect now!
... waiting

[ OK ]
** /etc/init.d/apache2 start
* Starting web server apache2

Syntax error on line 1 of
/etc/apache2/ports.conf:
Invalid command 'If', perhaps misspelled or defined by a module not
included in the server configuration


[fail]
"/usr/bin/ruby"
** ln -s /etc/apache2/mods-available/rewrite.load
/etc/apache2/mods-enabled/rewrite.load
** ln -s /etc/apache2/mods-available/ssl.conf /etc/apache2/mods-enabled/ssl.conf
** ln -s /etc/apache2/mods-available/ssl.load /etc/apache2/mods-enabled/ssl.load
** cp /opt/automate/dist///etc/apache2/sites-available/nova.panztel.biz.conf
/etc/apache2/sites-available/nova.panztel.biz.conf
** ln -s /etc/apache2/sites-available/nova.panztel.biz.conf
/etc/apache2/sites-enabled/nova.panztel.biz.conf
** cp /opt/automate/dist///etc/apache2/sites-available/novademo.panztel.com.conf
/etc/apache2/sites-available/novademo.panztel.com.conf
** ln -s /etc/apache2/sites-available/novademo.panztel.com.conf
/etc/apache2/sites-enabled/novademo.panztel.com.conf
** cp /opt/automate/dist///etc/apache2/sites-available/novamob.panztel.biz.conf
/etc/apache2/sites-available/novamob.panztel.biz.conf
** ln -s /etc/apache2/sites-available/novamob.panztel.biz.conf
/etc/apache2/sites-enabled/novamob.panztel.biz.conf
** cp /opt/automate/dist///etc/apache2/sites-available/novaqa.panztel.com.conf
/etc/apache2/sites-available/novaqa.panztel.com.conf
** ln -s /etc/apache2/sites-available/novaqa.panztel.com.conf
/etc/apache2/sites-enabled/novaqa.panztel.com.conf
** cp /opt/automate/dist///etc/apache2/sites-available/novatest.panztel.biz.conf
/etc/apache2/sites-available/novatest.panztel.biz.conf
** ln -s /etc/apache2/sites-available/novatest.panztel.biz.conf
/etc/apache2/sites-enabled/novatest.panztel.biz.conf
** cp /opt/automate/dist///etc/apache2/sites-available/provider.ezitracker.net.conf
/etc/apache2/sites-available/provider.ezitracker.net.conf
** ln -s /etc/apache2/sites-available/provider.ezitracker.net.conf
/etc/apache2/sites-enabled/provider.ezitracker.net.conf

Igal Koshevoy

unread,
Nov 11, 2009, 9:07:36 PM11/11/09
to autom...@googlegroups.com
I've struggled with the issue of what to do about services failing to
start/stop/restart as well, and how hard AutomateIt should try to ensure
that these succeeded.

The "service_manager.restart" is effectively calling
"/etc/init.d/apache2 restart" on your system performs no other checks to
confirm that this succeeded. The exit values from init.d scripts aren't
standardized, so trying to guess what they mean is risky.

Would the following approach be more reasonable? Try to
start/stop/restart the service, and confirm it by checking for a certain
amount of time till it assumes it either successfully completes, or the
timeout is reached and an exception is thrown.

For example:

# Tell Apache to start and wait up to 30 seconds
# for it to start, else raise exception:
service_manager.start "apache", :confirm => 30

# Same but use some sensible default number of seconds:
service_manager.start "apache", :confirm => true

# Configure a default confirmation, like in the Project's
# "automateit_env.rb" file to provide a default value:
service_manager.setup(:confirm => 30)
# And then following start/stop/restart calls will confirm by default:
service_manager.start "apache"
# Unless you deliberately tell them not to:
service_manager.start "apache", :confirm => false

Thoughts?

-igal
> --
>
> You received this message because you are subscribed to the Google Groups "AutomateIt" group.
> To post to this group, send email to autom...@googlegroups.com.
> To unsubscribe from this group, send email to automateit+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/automateit?hl=.
>
>
>

Tim Uckun

unread,
Nov 11, 2009, 11:29:47 PM11/11/09
to autom...@googlegroups.com
>
> Thoughts?
>

My main concern is that this is going to run unattended and I am not
going to know that a service failed to start. Maybe that's not really
important because I intend to set up zabbix monitoring on all my
machines and zabbix can tell me if something is not running but I can
see a situation where I have not set up the machine on zabbix yet or
something and some important service is not running.

Right now I have something like this.

begin
raise "Sorry, this platform is not supported" unless tagged?("ubuntu")

invoke 'facts'
invoke 'automateit'
invoke Facts.hostname

rescue => e
process_errors e
ensure
report_to_zabbix #reports the gathered facts to zabbix
end

Yes I am back to my old habit of doing things host centric :)

The process_errors will email me the exception and the stacktrace. If
an exception doesn't get raised obviously I get notified.

I could very easily put

raise "Apache not running" unless service_manager.started? ('apache2')

at the end of my script and that would be good enough for me. That
might be better than interrupting the whole run too but I need to
think about that a while.

In fact I was thinking today that I have too many
"service_manager.restart "apache2" if modified" lines in my scripts.
I might set a global Facts.restart_apache = true in the various
recipes so that I could just restart the service once at the end.


BTW. zabbix and automateit go really well together. Automateit runs
serverless and zabbix can report, chart, store, and alarm on any
value; therefore you can use zabbix to monitor all your servers and
raise alarms if any server doesn't report in a timely manner or any
arbitrary value goes out of threshold.
Reply all
Reply to author
Forward
0 new messages