--- loncom/init.d/loncontrol 2004/12/02 21:16:56 1.22 +++ loncom/init.d/loncontrol 2006/01/28 11:21:42 1.27 @@ -1,5 +1,7 @@ #!/usr/bin/perl # +# $Id: loncontrol,v 1.27 2006/01/28 11:21:42 albertel Exp $ +# # The LearningOnline Network with CAPA # # Copyright Michigan State University Board of Trustees @@ -45,6 +47,12 @@ $ENV{'BASH_ENV'}=""; # Firewall code is based on the code in FC2 /etc/init.d/ntpd my $fw_chain = 'RH-Firewall-1-INPUT'; my $iptables = '/sbin/iptables'; + if (! -e $iptables) { + $iptables = '/usr/sbin/iptables'; + if (! -e $iptables) { + print("Unable to find iptables command\n"); + } + } my $lond_port = 5663; my $lonhttpd_port = 8080; @@ -120,16 +128,16 @@ sub stop_daemon { my ($daemon,$killallname)=@_; my $pidfile="/home/httpd/perl/logs/$daemon.pid"; - printf("%-10s ",$daemon); + printf("%-15s ",$daemon); if (-e $pidfile) { open(PIDFILE,$pidfile); my $daemonpid=; chomp($daemonpid); kill TERM => $daemonpid; - sleep 2; + sleep 1; if (kill 0 => $daemonpid) { kill KILL => $daemonpid; - sleep 2; + sleep 1; if (kill 0 => $daemonpid) { print("failed to kill"); } else { @@ -146,6 +154,7 @@ sub stop_daemon { system("killall -q $killallname"); print(", killed off extraneous processes"); } + unlink($pidfile); print("\n"); } @@ -153,16 +162,16 @@ sub stop_daemon { if (($command eq "restartold") or ($command eq "reloadold")) { print 'Restarting LON-CAPA'."\n"; print 'Ending LON-CAPA client and daemon processes'."\n"; - foreach my $daemon ('lonsql','lond','lonc','lonhttpd') { + foreach my $daemon ('lonsql','lond','lonc','lonhttpd','lonmemcached') { &stop_daemon($daemon,$daemon); } print 'Starting LON-CAPA client and daemon processes (please be patient)'. "\n"; system("su www -c '/home/httpd/perl/loncron --oldlonc --justcheckdaemons'"); -} elsif (($command eq "restart") or ($command eq "reload")) { +} elsif ($command eq "restart") { print 'Restarting LON-CAPA'."\n"; print 'Ending LON-CAPA client and daemon processes'."\n"; - foreach my $daemon ('lonsql','lond','lonc','lonhttpd') { + foreach my $daemon ('lonsql','lond','lonc','lonhttpd','lonmemcached') { my $killallname=$daemon; if ($daemon eq 'lonc') { $killallname='loncnew'; } &stop_daemon($daemon,$killallname); @@ -172,7 +181,7 @@ if (($command eq "restartold") or ($comm system("su www -c '/home/httpd/perl/loncron --justcheckdaemons'"); } elsif ($command eq "stop") { print 'Stopping LON-CAPA'."\n"; - foreach my $daemon ('lonsql','lond','lonc','lonhttpd') { + foreach my $daemon ('lonsql','lond','lonc','lonhttpd','lonmemcached') { my $killallname=$daemon; if ($daemon eq 'lonc') { $killallname='loncnew'; } &stop_daemon($daemon,$killallname); @@ -190,6 +199,9 @@ if (($command eq "restartold") or ($comm print 'Starting LON-CAPA client and daemon processes (please be patient)'. "\n"; system("su www -c '/home/httpd/perl/loncron --justcheckdaemons'"); +} elsif ($command eq "reload") { + print 'Reload LON-CAPA config files'."\n"; + system("su www -c '/home/httpd/perl/loncron --justreload'"); } elsif ($command eq "status") { $response=`/bin/cat /home/httpd/perl/logs/*.pid 2>&1`; if ($response=~/No such file or directory/) {