diff options
author | Jay Bonci <jaybonci@debian.org> | 2004-05-16 03:12:19 +0000 |
---|---|---|
committer | Jay Bonci <jaybonci@debian.org> | 2004-05-16 03:12:19 +0000 |
commit | 6fb61adae4f45b229d2e91fd9e3616aa0ee5e3c5 (patch) | |
tree | bb2484097bc4fb745410545ac57c01b02f37ffbc /scripts/start-memcached | |
parent | 3802f0985bfcbfe8a70542fb0dadd10234fce3c0 (diff) | |
download | memcached-6fb61adae4f45b229d2e91fd9e3616aa0ee5e3c5.tar.gz |
Hey there Brad,
I'm just kicking an update of the newest memcached into the Debian
archive. You've added a few flags, so the manpage / default conf file
got updated. Also, start-memcached got a couple of fixes.
If you'd like to look them over and possibly commit them to your tree,
that'd be great. Attached is the pretty simple diff.
--jay
git-svn-id: http://code.sixapart.com/svn/memcached/trunk@201 b0b603af-a30f-0410-a34e-baf09ae79d0b
Diffstat (limited to 'scripts/start-memcached')
-rwxr-xr-x | scripts/start-memcached | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/scripts/start-memcached b/scripts/start-memcached index f71bc21..d4a3758 100755 --- a/scripts/start-memcached +++ b/scripts/start-memcached @@ -1,7 +1,7 @@ #!/usr/bin/perl -w # start-memcached -# 2003 - Jay Bonci <jaybonci@debian.org> +# 2003/2004 - Jay Bonci <jaybonci@debian.org> # This script handles the parsing of the /etc/memcached.conf file # and was originally created for the Debian distribution. # Anyone may use this little script under the same terms as @@ -16,9 +16,41 @@ if($> != 0 and $< != 0) } my $params; my $etchandle; my $etcfile = "/etc/memcached.conf"; + +# This script assumes that memcached is located at /usr/bin/memcached, and +# that the pidfile is writable at /var/run/memcached.pid + my $memcached = "/usr/bin/memcached"; my $pidfile = "/var/run/memcached.pid"; +# If we don't get a valid logfile parameter in the /etc/memcached.conf file, +# we'll just throw away all of our in-daemon output. We need to re-tie it so +# that non-bash shells will not hang on logout. Thanks to Michael Renner for +# the tip +my $fd_reopened = "/dev/null"; + + sub handle_logfile + { + my ($logfile) = @_; + $fd_reopened = $logfile; + } + + sub reopen_logfile + { + my ($logfile) = @_; + + open *STDERR, ">>$logfile"; + open *STDOUT, ">>$logfile"; + open *STDIN, ">>/dev/null"; + $fd_reopened = $logfile; + } + +# This is set up in place here to support other non -[a-z] directives + +my $conf_directives = { + "logfile" => \&handle_logfile, +}; + if(open $etchandle, $etcfile) { foreach my $line (<$etchandle>) @@ -28,7 +60,14 @@ if(open $etchandle, $etcfile) $line =~ s/\s+$//g; $line =~ s/^\s+//g; next unless $line; - next if $line =~ /\-[dvh]/; + next if $line =~ /^\-[dh]/; + + if($line =~ /^[^\-]/) + { + my ($directive, $arg) = $line =~ /^(.*?)\s+(.*)/; + $conf_directives->{$directive}->($arg); + next; + } push @$params, $line; } @@ -61,6 +100,7 @@ my $pid = fork(); if($pid == 0) { + reopen_logfile($fd_reopened); exec "$memcached $params"; exit(0); |