[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#708184: collab-qa/cloud-scripts/masternode: Add support for specifying output directory



On Lunes, 13 de mayo de 2013 22:37:30 Nathaniel Harrison Handler escribió:
> Package: qa.debian.org
> Severity: wishlist
> 
> Currently, when the masternode script is run, logs are copied to /tmp/logs
> automatically. It would be nice to support specifying an alternate
> directory for the logs. This would allow multiple instances of masternode
> to run simultaneously on the same machine without interfering with each
> other.
> 
> -- System Information:
> Debian Release: 6.0.7
> Architecture: amd64 (x86_64)
> Kernel: Linux 2.6.32-5-amd64 (SMP w/4 CPU cores)
> Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
> Shell: /bin/sh linked to /bin/dash

Hi,

Patch attached.

David
--- masternode.ori	2013-05-12 13:45:13.000000000 +0200
+++ masternode	2013-05-17 23:46:15.000000000 +0200
@@ -19,6 +19,7 @@
 $halt_nodes = true
 $reprepro = nil
 $reprepro_lock = Mutex::new
+$logs_dir = "/tmp/logs/"
 SLEEPTIME=60
 
 options = OptionParser::new do |opts|
@@ -40,6 +41,11 @@
   opts.on("", "--reprepro CODENAME", "Upload built packages to reprepro") do |c|
     $reprepro = c
   end
+  opts.on("-d", "--logs-dir LOGSDIR", "Put build logs in LOGSDIR, defaults to /tmp/logs") do |d|
+    # force final trailing separator but let's try not to be fascist about
+    d += File::SEPARATOR unless d[-1] == File::SEPARATOR
+    $logs_dir = d
+  end
   opts.on("-o", "--output LOGFILE", "Specify logfile for output") do |n|
     log = File::new(n, "w")
     STDOUT.reopen(log)
@@ -47,6 +53,7 @@
     STDOUT.sync = true
     STDERR.sync = true
   end
+
 end
 options.parse!(ARGV)
 
@@ -161,7 +168,7 @@
 $tasks_mutex = Mutex::new
 $retry_tasks = []
 
-FileUtils::mkdir_p("/tmp/logs/")
+FileUtils::mkdir_p($logs_dir)
 
 def execute_one_task(node, slot, ssh, scp, task)
   tname = task['source'] || task['package'] if not task.nil?
@@ -176,9 +183,9 @@
   begin
     scp.upload!(f.path, "/tmp/")
     ssh.exec!("/root/process-task -t #{f.path}")
-    scp.download!(task['logfile'], "/tmp/logs/")
+    scp.download!(task['logfile'], $logs_dir)
     ssh.exec!("rm -f #{f.path} #{task['logfile']}")
-    status = IO::read("/tmp/logs/#{File::basename(task['logfile'])}").split(/\n/).grep(/^DC-Status: /)
+    status = IO::read("#{$logs_dir}#{File::basename(task['logfile'])}").split(/\n/).grep(/^DC-Status: /)
     if status.empty? or status[0].split[1] != 'OK'
       res = :failed
     else

Attachment: masternode-add-alternate-dir.patch.asc
Description: PGP signature


Reply to: