[Socialtext-commits] SF.net SVN: socialtext: [986] branches/rug/etc/init.d
Brought to you by:
socialtextrocks
|
From: <pet...@us...> - 2007-01-30 02:39:14
|
Revision: 986
http://svn.sourceforge.net/socialtext/?rev=986&view=rev
Author: petdance
Date: 2007-01-29 18:39:12 -0800 (Mon, 29 Jan 2007)
Log Message:
-----------
No need to generate the etc/init.d scripts from .in any more
Added Paths:
-----------
branches/rug/etc/init.d/ceqlotron
branches/rug/etc/init.d/st-apache
Removed Paths:
-------------
branches/rug/etc/init.d/ceqlotron.in
branches/rug/etc/init.d/st-apache.in
Copied: branches/rug/etc/init.d/ceqlotron (from rev 971, branches/rug/etc/init.d/ceqlotron.in)
===================================================================
--- branches/rug/etc/init.d/ceqlotron (rev 0)
+++ branches/rug/etc/init.d/ceqlotron 2007-01-30 02:39:12 UTC (rev 986)
@@ -0,0 +1,60 @@
+#!/usr/bin/perl
+# @COPYRIGHT@
+#
+# ceqlotron Start/stop Socialtext ceqlotron daemon.
+
+use warnings;
+use strict;
+
+use Carp 'croak';
+use Readonly;
+use Socialtext::InitFunctions qw(
+ fork_and_exec_daemon_as_user system_or_die try_kill timeout_waitpid
+ succeed fail restart assert_absolute_paths
+);
+
+Readonly my $NAME => 'ceqlotron';
+Readonly my $CEQLOTRON => '@PREFIX@@BINDIR@/ceqlotron';
+Readonly my $PIDFILE => '@PREFIX@@PIDDIR@/ceqlotron.pid';
+Readonly my $LOGFILE => '@PREFIX@@CEQLOTRON_LOGFILE@';
+Readonly my $USER => '@ST_USER@';
+Readonly my @CEQ_START => ( $CEQLOTRON, "--output=$LOGFILE" );
+
+assert_absolute_paths(
+ 'ceqltron' => $CEQLOTRON,
+ 'PID file' => $PIDFILE,
+ 'path file' => $LOGFILE,
+);
+
+my ( $uid, $gid ) = ( getpwnam $USER )[ 2, 3 ] or die "getwpnam $USER: $!";
+
+$| = 1;
+
+my $operation = shift || '';
+if ( $operation eq 'start' ) {
+ print "Starting $NAME... ";
+ system_or_die( 'touch', $LOGFILE );
+ chown $uid, $gid, $LOGFILE or die "chown $uid $gid $LOGFILE: $!\n";
+
+ if ((my $code = fork_and_exec_daemon_as_user( $USER, @CEQ_START )) == 0) {
+ succeed 'done.';
+ } else {
+ fail "nonzero exit: $code.";
+ }
+}
+elsif ( $operation eq 'stop' ) {
+ print "Stopping $NAME... ";
+ fail "$PIDFILE does not exist." unless -f $PIDFILE;
+ chomp( my $pid = `cat $PIDFILE` );
+ try_kill( 'TERM', $pid ) or fail 'already stopped.';
+ while ( !timeout_waitpid( $pid, 60 ) ) {
+ try_kill( 'INT', $pid ) or succeed 'done.';
+ }
+ succeed 'done.';
+}
+elsif ( $operation eq 'restart' ) {
+ restart();
+}
+else {
+ fail "Usage: $0 {start|stop|restart}";
+}
Deleted: branches/rug/etc/init.d/ceqlotron.in
===================================================================
--- branches/rug/etc/init.d/ceqlotron.in 2007-01-30 02:36:07 UTC (rev 985)
+++ branches/rug/etc/init.d/ceqlotron.in 2007-01-30 02:39:12 UTC (rev 986)
@@ -1,60 +0,0 @@
-#!/usr/bin/perl
-# @COPYRIGHT@
-#
-# ceqlotron Start/stop Socialtext ceqlotron daemon.
-
-use warnings;
-use strict;
-
-use Carp 'croak';
-use Readonly;
-use Socialtext::InitFunctions qw(
- fork_and_exec_daemon_as_user system_or_die try_kill timeout_waitpid
- succeed fail restart assert_absolute_paths
-);
-
-Readonly my $NAME => 'ceqlotron';
-Readonly my $CEQLOTRON => '@PREFIX@@BINDIR@/ceqlotron';
-Readonly my $PIDFILE => '@PREFIX@@PIDDIR@/ceqlotron.pid';
-Readonly my $LOGFILE => '@PREFIX@@CEQLOTRON_LOGFILE@';
-Readonly my $USER => '@ST_USER@';
-Readonly my @CEQ_START => ( $CEQLOTRON, "--output=$LOGFILE" );
-
-assert_absolute_paths(
- 'ceqltron' => $CEQLOTRON,
- 'PID file' => $PIDFILE,
- 'path file' => $LOGFILE,
-);
-
-my ( $uid, $gid ) = ( getpwnam $USER )[ 2, 3 ] or die "getwpnam $USER: $!";
-
-$| = 1;
-
-my $operation = shift || '';
-if ( $operation eq 'start' ) {
- print "Starting $NAME... ";
- system_or_die( 'touch', $LOGFILE );
- chown $uid, $gid, $LOGFILE or die "chown $uid $gid $LOGFILE: $!\n";
-
- if ((my $code = fork_and_exec_daemon_as_user( $USER, @CEQ_START )) == 0) {
- succeed 'done.';
- } else {
- fail "nonzero exit: $code.";
- }
-}
-elsif ( $operation eq 'stop' ) {
- print "Stopping $NAME... ";
- fail "$PIDFILE does not exist." unless -f $PIDFILE;
- chomp( my $pid = `cat $PIDFILE` );
- try_kill( 'TERM', $pid ) or fail 'already stopped.';
- while ( !timeout_waitpid( $pid, 60 ) ) {
- try_kill( 'INT', $pid ) or succeed 'done.';
- }
- succeed 'done.';
-}
-elsif ( $operation eq 'restart' ) {
- restart();
-}
-else {
- fail "Usage: $0 {start|stop|restart}";
-}
Copied: branches/rug/etc/init.d/st-apache (from rev 985, branches/rug/etc/init.d/st-apache.in)
===================================================================
--- branches/rug/etc/init.d/st-apache (rev 0)
+++ branches/rug/etc/init.d/st-apache 2007-01-30 02:39:12 UTC (rev 986)
@@ -0,0 +1,70 @@
+#!/usr/bin/perl
+# @COPYRIGHT@
+#
+# st-apache Start the Apache HTTP server with Socialtext configuration.
+
+use warnings;
+use strict;
+
+use Carp 'croak';
+use Readonly;
+use Socialtext::Build qw( get_build_setting );
+use Socialtext::InitFunctions qw(
+ fork_and_exec_daemon_as_user system_or_die try_kill timeout_waitpid
+ succeed fail restart
+);
+
+# XXX Hoist into a module
+my $webapi = get_build_setting( 'webapi' );
+my $short_name = $webapi eq 'mod_perl1' ? 'apache-perl' : 'apache2';
+
+Readonly my $NAME => 'st-apache';
+Readonly my $CONF => '@PREFIX@@HTTPD_CONFDIR@/st-httpd.conf';
+Readonly my $DAEMON => '@HTTPD@';
+Readonly my @COMMAND => ($DAEMON, '-f', $CONF);
+Readonly my $PIDFILE => "@PREFIX@@HTTPD_PIDDIR@/$short_name.pid";
+Readonly my $PERL => '@PERL@';
+Readonly my $USER => 'root';
+
+$ENV{LANG} = 'C';
+$ENV{PATH} = '/sbin:/bin:/usr/bin:/usr/local/bin';
+
+my $operation = shift || '';
+if ($operation eq 'start') {
+ print "Starting $NAME web server... ";
+ if ((my $code = fork_and_exec_daemon_as_user( $USER, @COMMAND )) == 0) {
+ succeed 'done.';
+ }
+ else {
+ fail "nonzero exit: $code.";
+ }
+}
+elsif ($operation eq 'stop') {
+ print "Stopping $NAME web server... ";
+ my $pid = get_pid();
+ try_kill( 15, $pid ) or fail 'already stopped.';
+ if (timeout_waitpid($pid, 300)) {
+ succeed 'done.';
+ }
+ else {
+ fail 'timed out waiting for exit.';
+ }
+}
+elsif ($operation eq 'restart') {
+ restart();
+}
+elsif ($operation =~ /^(?:force-)?reload$/) {
+ print "Signalling $NAME to reload...";
+ my $pid = get_pid();
+ try_kill("USR1", $pid) or fail 'no running process.';
+ succeed 'done.';
+}
+else {
+ fail "Usage: $0 {start|stop|restart}";
+}
+
+sub get_pid {
+ fail "$PIDFILE does not exist." unless -f $PIDFILE;
+ chomp( my $pid = `cat $PIDFILE` );
+ return $pid;
+}
Deleted: branches/rug/etc/init.d/st-apache.in
===================================================================
--- branches/rug/etc/init.d/st-apache.in 2007-01-30 02:36:07 UTC (rev 985)
+++ branches/rug/etc/init.d/st-apache.in 2007-01-30 02:39:12 UTC (rev 986)
@@ -1,70 +0,0 @@
-#!/usr/bin/perl
-# @COPYRIGHT@
-#
-# st-apache Start the Apache HTTP server with Socialtext configuration.
-
-use warnings;
-use strict;
-
-use Carp 'croak';
-use Readonly;
-use Socialtext::Build qw( get_build_setting );
-use Socialtext::InitFunctions qw(
- fork_and_exec_daemon_as_user system_or_die try_kill timeout_waitpid
- succeed fail restart
-);
-
-# XXX Hoist into a module
-my $webapi = get_build_setting( 'webapi' );
-my $short_name = $webapi eq 'mod_perl1' ? 'apache-perl' : 'apache2';
-
-Readonly my $NAME => 'st-apache';
-Readonly my $CONF => '@PREFIX@@HTTPD_CONFDIR@/st-httpd.conf';
-Readonly my $DAEMON => '@HTTPD@';
-Readonly my @COMMAND => ($DAEMON, '-f', $CONF);
-Readonly my $PIDFILE => "@PREFIX@@HTTPD_PIDDIR@/$short_name.pid";
-Readonly my $PERL => '@PERL@';
-Readonly my $USER => 'root';
-
-$ENV{LANG} = 'C';
-$ENV{PATH} = '/sbin:/bin:/usr/bin:/usr/local/bin';
-
-my $operation = shift || '';
-if ($operation eq 'start') {
- print "Starting $NAME web server... ";
- if ((my $code = fork_and_exec_daemon_as_user( $USER, @COMMAND )) == 0) {
- succeed 'done.';
- }
- else {
- fail "nonzero exit: $code.";
- }
-}
-elsif ($operation eq 'stop') {
- print "Stopping $NAME web server... ";
- my $pid = get_pid();
- try_kill( 15, $pid ) or fail 'already stopped.';
- if (timeout_waitpid($pid, 300)) {
- succeed 'done.';
- }
- else {
- fail 'timed out waiting for exit.';
- }
-}
-elsif ($operation eq 'restart') {
- restart();
-}
-elsif ($operation =~ /^(?:force-)?reload$/) {
- print "Signalling $NAME to reload...";
- my $pid = get_pid();
- try_kill("USR1", $pid) or fail 'no running process.';
- succeed 'done.';
-}
-else {
- fail "Usage: $0 {start|stop|restart}";
-}
-
-sub get_pid {
- fail "$PIDFILE does not exist." unless -f $PIDFILE;
- chomp( my $pid = `cat $PIDFILE` );
- return $pid;
-}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|