File:  [LON-CAPA] / loncom / lonmemcached
Revision 1.8: download - view: text, annotated - select for diffs
Sun Apr 27 22:15:30 2025 UTC (6 days, 16 hours 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.

#!/usr/bin/perl
# $Id: lonmemcached,v 1.8 2025/04/27 22:15:30 raeburn Exp $

$pidfile="/home/httpd/perl/logs/lonmemcached.pid";
$logfile="/home/httpd/perl/logs/lonmemcached.log";

if (-e $pidfile) {
   open(LFH,"$pidfile");
   my $pide=<LFH>;
   chomp($pide);
   close(LFH);
   if (kill 0 => $pide) { die "already running $pide"; }
}

if ($pid=fork()) { exit; }
open (PIDSAVE,">$pidfile");
print PIDSAVE "$$\n";
close(PIDSAVE);

my @args = ('-m','400','-l','127.0.0.1','-p','11211','-U','0','-v');
if (-e '/usr/sbin/memcached') {
    unshift(@args,'/usr/sbin/memcached');
    exec( { $args[0] } @args);
} elsif (-e '/usr/bin/memcached') {
    unshift(@args,'/usr/bin/memcached');
    exec( { $args[0] } @args);
} else {
    die("Unable to find memcached");
}

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