Commits

Anonymous committed 77821dc

new work to write to a dedicated log file and to background the worker

Comments (0)

Files changed (8)

         #ssh root@$hostname "cd $DIR && export HOSTNAME && nohup ./bin/jexec peregrine.worker.Main -h=$host > $LOGDIR/peregrine-$host.log 2> $LOGDIR/peregrine-$host.err &" 
 
         set -x
-        ssh root@$hostname "cd $DIR && nohup ./bin/workerd -h=$host > $LOGDIR/peregrine-$host.log 2> $LOGDIR/peregrine-$host.err &" 
+
+        #ssh -v root@$hostname "cd $DIR && nohup ./bin/workerd --host=$host > $LOGDIR/peregrine-$host.log 2> $LOGDIR/peregrine-$host.err & " 
+        #ssh root@$hostname "cd $DIR && nohup ./bin/workerd --host=$host & " 
+
+        ssh root@$hostname "cd $DIR && ./bin/workerd --host=$host > $LOGDIR/peregrine-$host.log 2> /dev/stdout" 
+
         set +x
 
     done
 ulimit -n 32768
 ulimit -l unlimited
 
-./bin/jexec peregrine.worker.Main $@
+./bin/jexec peregrine.worker.Main $@ &
     <appender name="console" class="org.apache.log4j.ConsoleAppender">
 
         <layout class="org.apache.log4j.PatternLayout">
-            <param name="ConversionPattern" value="%d{ISO8601} %X{server.hostname} %p [%t] %c %m%n"/>     
+            <param name="ConversionPattern" value="%d{ISO8601} %p [%t] %c %m%n"/>     
     
         </layout>
 
 
     <appender name="file" class="org.apache.log4j.RollingFileAppender">
 	
-	        <param name="File" value="logs/peregrine.log" />
+	        <param name="File" value="logs/peregrine-${peregrine.host}.log" />
 	        <param name="MaxFileSize" value="100MB" />
 	        <param name="MaxBackupIndex" value="1" />
 	
 	        <layout class="org.apache.log4j.PatternLayout">
-	          <param name="ConversionPattern" value="%d{ISO8601} %X{server.hostname} %p [%t] %c %m%n"/>   
+	          <param name="ConversionPattern" value="%d{ISO8601} %p [%t] %c %m%n"/>   
 	        </layout>
 
     </appender>
 
     <root>
         <level value="INFO" />
-        <appender-ref ref="console"/>
+        <!-- <appender-ref ref="console"/> -->
         <appender-ref ref="file"/>
     </root>
 

src/java/peregrine/config/BaseConfig.java

 import peregrine.util.*;
 import peregrine.os.*;
 
-import com.spinn3r.log5j.Logger;
-
 /**
  * Holds all the main properties for a Config including getters and setters.
  * 

src/java/peregrine/config/ConfigParser.java

 import peregrine.util.*;
 import peregrine.os.*;
 
-import com.spinn3r.log5j.Logger;
-
 /**
  * Handles parsing the peregrine.conf file and the peregrine.hosts file as well
  * as handling command line arguments.
  */
 public class ConfigParser {
 
-    protected static final Logger log = Logger.getLogger();
-
     /**
      * Parse without any command line arguments.
      */

src/java/peregrine/os/unistd.java

         delegate.sync();
     }
 
+    public static int getpid() {
+        return delegate.getpid();
+    }
+    
     interface InterfaceDelegate extends Library {
         void sync();
+        int getpid();
     }
 
 }

src/java/peregrine/worker/Initializer.java

+/*
+ * Copyright 2011 Kevin A. Burton
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+package peregrine.worker;
+
+import java.util.*;
+
+import peregrine.config.*;
+
+import org.apache.log4j.xml.DOMConfigurator;
+
+/**
+ * Initializer for bringing up the system. 
+ */
+public final class Initializer {
+
+    public static void doInitLogger( Config config ) {
+
+        System.setProperty( "peregrine.host", "" + config.getHost() );
+
+        DOMConfigurator.configure( "conf/log4j.xml" );
+
+    }
+    
+}

src/java/peregrine/worker/Main.java

 package peregrine.worker;
 
 import peregrine.config.*;
-import org.apache.log4j.xml.DOMConfigurator;
 
 import com.spinn3r.log5j.Logger;
 
         
     public static void main(String[] args ) throws Exception {
 
-        DOMConfigurator.configure( "conf/log4j.xml" );
         config = ConfigParser.parse( args );
+        Initializer.doInitLogger( config );
 
         log.info( "Starting on %s with controller: %s" , config.getHost(), config.getController() );
         
         new FSDaemon( config );
+
+        System.out.printf( "Daemon up and running on %s\n", config.getHost() );
         
         Thread.sleep( Long.MAX_VALUE );