From e9a9ae186c8972adb565ee296ea5987d5048b583 Mon Sep 17 00:00:00 2001 From: James Kolpack Date: Wed, 4 May 2016 10:47:04 -0400 Subject: [PATCH] Add option to suppress storage copy for testing --- Core/Remote/PiscalLeafInput.cs | 1 + Core/Remote/PiscalSshClient.cs | 4 ++++ Core/Remote/piscal_launcher.sh | 12 +++++++++--- Core/Remote/piscal_manager.sh | 10 +++++++++- Web/Services/PiscalQueue/PiscalService.cs | 3 +++ 5 files changed, 26 insertions(+), 4 deletions(-) diff --git a/Core/Remote/PiscalLeafInput.cs b/Core/Remote/PiscalLeafInput.cs index 3d0e09b..74b3fc3 100644 --- a/Core/Remote/PiscalLeafInput.cs +++ b/Core/Remote/PiscalLeafInput.cs @@ -11,6 +11,7 @@ namespace LeafWeb.Core.Remote public int LeafInputId { get; set; } public string PhotosyntheticType { get; set; } public string DirectoryName { get; set; } + public bool SuppressStorageCopy { get; set; } public PiscalLeafInputFile[] InputFiles { get; set; } static PiscalLeafInput() diff --git a/Core/Remote/PiscalSshClient.cs b/Core/Remote/PiscalSshClient.cs index 664aef1..0997f0f 100644 --- a/Core/Remote/PiscalSshClient.cs +++ b/Core/Remote/PiscalSshClient.cs @@ -69,6 +69,10 @@ namespace LeafWeb.Core.Remote { ssh.Connect(); var commandText = $"{RemoteScriptPath} -d {leafInput.DirectoryName} -p {leafInput.PhotosyntheticType} -s"; + + if (leafInput.SuppressStorageCopy) + commandText += " -t"; + var command = ssh.CreateCommand(commandText); command.Execute(); ssh.Disconnect(); diff --git a/Core/Remote/piscal_launcher.sh b/Core/Remote/piscal_launcher.sh index 231132d..dac662f 100644 --- a/Core/Remote/piscal_launcher.sh +++ b/Core/Remote/piscal_launcher.sh @@ -7,6 +7,7 @@ where: -h show this help text -d working directory -f input filename + -t suppress storage copy -u url to notify on completion" # http://stackoverflow.com/a/246128/99492 @@ -23,7 +24,7 @@ notify_url="" # $piscal_executable and $storage_directory . "$base_directory/piscal_launcher.cfg" -while getopts "hd:f:u:" opt; do +while getopts "hd:f:u:t" opt; do case "$opt" in h ) echo "$usage" @@ -32,6 +33,9 @@ while getopts "hd:f:u:" opt; do d ) working_directory=$OPTARG ;; + t ) + suppress_storage_copy=true + ;; u ) notify_url=$OPTARG ;; @@ -93,8 +97,10 @@ fi popd >> /dev/null # copy output to storage -cp "$output_directory_touser"/* "$storage_directory"/ -cp "$output_directory_nottouser"/* "$storage_directory"/ +if [ -z "$suppress_storage_copy" ]; then + cp "$output_directory_touser"/* "$storage_directory"/ + cp "$output_directory_nottouser"/* "$storage_directory"/ +fi # notify given url of completion if [ -z "$notify_url" ]; then diff --git a/Core/Remote/piscal_manager.sh b/Core/Remote/piscal_manager.sh index 6c68038..2e7e08e 100644 --- a/Core/Remote/piscal_manager.sh +++ b/Core/Remote/piscal_manager.sh @@ -8,6 +8,7 @@ where: -d working directory name -p photosynthetic type -s start job + -t suppress storage copy -c cleanup directory -k kill job" @@ -27,7 +28,7 @@ launcher="$base_directory/piscal_launcher.sh" # http://stackoverflow.com/a/14203146/99492 # http://wiki.bash-hackers.org/howto/getopts_tutorial -while getopts "hd:f:p:sck" opt; do +while getopts "hd:f:p:stck" opt; do #echo "$opt = $OPTARG" case "$opt" in h ) @@ -43,6 +44,9 @@ while getopts "hd:f:p:sck" opt; do s ) task="launch" ;; + t ) + suppress_storage_copy=true + ;; c ) task="cleanup" ;; @@ -75,6 +79,7 @@ pid_path="$working_directory/$pid_filename" ## Process task if [ "$task" = "launch" ]; then + # TODO: verify process isn't running yet piscal_config_file="$working_directory"/piscal.cfg # write config file for piscal echo $photosynthetic_type > "$piscal_config_file" @@ -83,6 +88,9 @@ if [ "$task" = "launch" ]; then >> "$piscal_config_file" command="$launcher -d $working_directory -f piscal.cfg" + if [ "$suppress_storage_copy" = true ]; then + command="$command -t" + fi # launch it, sending error output to file nohup ${command} > $working_directory/$stderr_filename 2>&1 & diff --git a/Web/Services/PiscalQueue/PiscalService.cs b/Web/Services/PiscalQueue/PiscalService.cs index ef77720..7fed022 100644 --- a/Web/Services/PiscalQueue/PiscalService.cs +++ b/Web/Services/PiscalQueue/PiscalService.cs @@ -24,6 +24,9 @@ namespace LeafWeb.Web.Services.PiscalQueue public void Run(LeafInput leafInput) { var inputFile = new PiscalLeafInput(leafInput); + // TODO: remove this, just for testing + if (string.Equals(leafInput.Email, "james.kolpack@gmail.com", StringComparison.InvariantCultureIgnoreCase)) + inputFile.SuppressStorageCopy = true; _piscalClient.RunLeafInput(inputFile); }