File:  [LON-CAPA] / loncom / init.d / loncontrol
Revision 1.15: download - view: text, annotated - select for diffs
Thu Dec 18 21:23:01 2003 UTC (20 years, 5 months ago) by albertel
Branches: MAIN
CVS tags: version_1_1_X, version_1_1_3, version_1_1_2, version_1_1_1, version_1_1_0, version_1_0_99_3, HEAD
- defaulting back to the old lonc

    1: #!/usr/bin/perl
    2: #
    3: # The LearningOnline Network with CAPA
    4: #
    5: # Startup script for the LON-CAPA network processes
    6: #
    7: # YEAR=2000
    8: # YEAR=2001
    9: # YEAR=2002
   10: 
   11: # chkconfig: 345 95 5
   12: # description: LON-CAPA is a "network of knowledge".  It is used to
   13: # distribute knowledge resources and instructional management.
   14: # processnames: lonc, lond, lonsql
   15: # pidfiles: /home/httpd/perl/logs/lon*.pid
   16: # config: /etc/httpd/conf/loncapa.conf
   17: # config: /home/httpd/lonTabs/hosts.tab
   18: # config: /home/httpd/lonTabs/spare.tab
   19: 
   20: $command=$ARGV[0]; $command=~s/[^a-z]//g;
   21: 
   22: $ENV{'PATH'}="/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin";
   23: $ENV{'BASH_ENV'}="";
   24: 
   25: sub stop_daemon {
   26:     my ($daemon)=@_;
   27:     my $pidfile="/home/httpd/perl/logs/$daemon.pid";
   28:     
   29:     printf("%-10s ",$daemon);
   30:     if (-e $pidfile) {
   31: 	open(PIDFILE,$pidfile);
   32: 	my $daemonpid=<PIDFILE>;
   33: 	chomp($daemonpid);
   34: 	kill TERM => $daemonpid;
   35: 	sleep 2;
   36: 	if (kill 0 => $daemonpid) {
   37: 	    kill KILL => $daemonpid;
   38: 	    sleep 2;
   39: 	    if (kill 0 => $daemonpid) {
   40: 		print("failed to kill\n"); return;
   41: 	    } else {
   42: 		print("killed\n"); return;
   43: 	    }
   44: 	} else {
   45: 	    print("stopped\n"); return;
   46: 	}
   47:     }
   48:     print("not running\n");
   49: }
   50: 
   51: if (($command eq "restart") or ($command eq "reload")) {
   52:     print 'Restarting LON-CAPA'."\n";
   53:     print 'Ending LON-CAPA client and daemon processes'."\n";
   54:     foreach my $daemon ('lonsql','lond','lonc','lonhttpd') {
   55: 	&stop_daemon($daemon);
   56:     }
   57:     print 'Starting LON-CAPA client and daemon processes (please be patient)'.
   58: 	"\n";
   59:     system("su -c '/home/httpd/perl/loncron' www");
   60: }
   61: elsif (($command eq "restartnew") or ($command eq "reloadnew")) {
   62:     print 'Restarting LON-CAPA'."\n";
   63:     print 'Ending LON-CAPA client and daemon processes'."\n";
   64:     foreach my $daemon ('lonsql','lond','lonc','lonhttpd') {
   65: 	&stop_daemon($daemon);
   66:     }
   67:     print 'Starting LON-CAPA client and daemon processes (please be patient)'.
   68: 	"\n";
   69:     system("su -c '/home/httpd/perl/loncron new' www");
   70: }
   71: elsif ($command eq "stop") {
   72:     print 'Stopping LON-CAPA'."\n";
   73:     foreach my $daemon ('lonsql','lond','lonc','lonhttpd') {
   74: 	&stop_daemon($daemon);
   75:     }
   76: }
   77: elsif ($command eq "start") {
   78:     print 'Starting LON-CAPA'."\n";
   79:     print 'Starting LON-CAPA client and daemon processes (please be patient)'.
   80: 	"\n"; 
   81:     system("su -c '/home/httpd/perl/loncron' www");
   82: }
   83: elsif ($command eq "startnew") {
   84:     print 'Starting LON-CAPA'."\n";
   85:     print 'Starting LON-CAPA client and daemon processes (please be patient)'.
   86: 	"\n"; 
   87:     system("su -c '/home/httpd/perl/loncron new' www");
   88: }
   89: elsif ($command eq "status") {
   90:     $response=`/bin/cat /home/httpd/perl/logs/*.pid 2>&1`;
   91:     if ($response=~/No such file or directory/) {
   92: 	print 'LON-CAPA is not running.'."\n";
   93:     }
   94:     else {
   95: 	print 'LON-CAPA is running.'."\n";
   96:     }
   97: }
   98: else {
   99:     print 'You need to specify restart|stop|start|status on the command line'.
  100: 	' argument.'."\n";
  101: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>