File:  [LON-CAPA] / loncom / lonmemcached
Revision 1.8: download - view: text, annotated - select for diffs
Sun Apr 27 22:15:30 2025 UTC (2 months ago) by raeburn
Branches: MAIN
CVS tags: version_2_12_X, HEAD
- Use indirect object notation in calls to exec(). Explicitly provide port
  number for tcp, no port for udp, and localhost as listener interface.

    1: #!/usr/bin/perl
    2: # $Id: lonmemcached,v 1.8 2025/04/27 22:15:30 raeburn Exp $
    3: 
    4: $pidfile="/home/httpd/perl/logs/lonmemcached.pid";
    5: $logfile="/home/httpd/perl/logs/lonmemcached.log";
    6: 
    7: if (-e $pidfile) {
    8:    open(LFH,"$pidfile");
    9:    my $pide=<LFH>;
   10:    chomp($pide);
   11:    close(LFH);
   12:    if (kill 0 => $pide) { die "already running $pide"; }
   13: }
   14: 
   15: if ($pid=fork()) { exit; }
   16: open (PIDSAVE,">$pidfile");
   17: print PIDSAVE "$$\n";
   18: close(PIDSAVE);
   19: 
   20: my @args = ('-m','400','-l','127.0.0.1','-p','11211','-U','0','-v');
   21: if (-e '/usr/sbin/memcached') {
   22:     unshift(@args,'/usr/sbin/memcached');
   23:     exec( { $args[0] } @args);
   24: } elsif (-e '/usr/bin/memcached') {
   25:     unshift(@args,'/usr/bin/memcached');
   26:     exec( { $args[0] } @args);
   27: } else {
   28:     die("Unable to find memcached");
   29: }

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