Log in |
Restarting Zope as a ServiceIf you run Zope as a service on Windows it can sometimes be nice to restart it through a script. I find this especially useful for cron jobs, when Zope stops responding and so on. Due to popular demand I include Python and Perl versions of the scripts... Python In Python use win32serviceutil: import win32serviceutil machine = 'cr582427-a' service = 'ZopeTest' def KickService(machine, service, action): if action=="start": try: win32serviceutil.StartService(service, machine) print "Service started" except: print "Service could not be started" elif action=="stop": try: win32serviceutil.StopService(service, machine) print "Service stopped" except: print "Service could not be stopped" KickService(machine, service, 'stop') KickService(machine, service, 'start') Perl In Perl you can use Win32::Service: use Win32::Service; my $machine = 'cr582427-a'; my $service = 'Zope'; print "Stopping\n"; Win32::Service::StopService($machine, $service); sleep 5; print "Starting\n"; Win32::Service::StartService($machine, $service); This of course assumes you know the name of the service. If you don't, Win32::Service can look it up: use Win32::Service; my $machine = 'cr582427-a'; my %hash; print Win32::Service::GetServices($machine, \%hash); foreach (keys %hash) { print $hash{$_}, "\n"; } |