Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 88 additions & 39 deletions alldata/hla_class/hla.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
<?php
ini_set("error_reporting","E_ALL & ~E_NOTICE");
session_start();
session_start();

$myfile = fopen("/alldata/bblab_site/logs/hla_debugging.log", "a");
fwrite($myfile, "----\n");
fwrite($myfile, date("h:i:sa Y-m-d") . " Opening HLA debugging log.\n");
$session_string_dump = print_r($_SESSION, true);
fwrite($myfile, "session: " . $_SESSION . "\n");
fwrite($myfile, "session results: " . $_SESSION["results"] . "\n");
fclose($myfile);

//hmmm
if ($_SESSION["results"]) {
Expand All @@ -9,52 +17,93 @@
unlink($_SESSION["tech_errors"]);
unlink($_SESSION["errors"]);
//posix_kill($_SESSION["pid"], 15); // SIGTERM, I hope.
}
}

if ($_SESSION["updates"]) {
unlink($_SESSION["updates"]);
}

$ruby = "ruby";
$script = dirname(__FILE__) . "/hla-easy.rb";
$_SESSION["results"] = dirname(__FILE__) . tempnam("/tmp", "");
$_SESSION["details"] = dirname(__FILE__) . tempnam("/tmp", "");
$_SESSION["tech_errors"] = dirname(__FILE__) . tempnam("/tmp", "");
$_SESSION["errors"] = dirname(__FILE__) . tempnam("/tmp", "");

$letter = $_POST["letter"];
if ($_SESSION["updates"]) {
unlink($_SESSION["updates"]);
}

$ruby = "/root/.rbenv/shims/ruby";
$script = dirname(__FILE__) . "/hla-easy.rb";
$_SESSION["results"] = dirname(__FILE__) . tempnam("/tmp", "");
$_SESSION["details"] = dirname(__FILE__) . tempnam("/tmp", "");
$_SESSION["tech_errors"] = dirname(__FILE__) . tempnam("/tmp", "");
$_SESSION["errors"] = dirname(__FILE__) . tempnam("/tmp", "");

$myfile = fopen("/alldata/bblab_site/logs/hla_debugging.log", "a");
$session_string_dump = print_r($_SESSION, true);
fwrite($myfile, "session (after setting some variables): " . $_SESSION . "\n");
fwrite($myfile, "session results: " . $_SESSION["results"] . "\n");
fwrite($myfile, "session details: " . $_SESSION["details"] . "\n");
fwrite($myfile, "session tech_errors: " . $_SESSION["tech_errors"] . "\n");
fwrite($myfile, "session errors: " . $_SESSION["errors"] . "\n");
fclose($myfile);

$letter = $_POST["letter"];
$threshold = $_POST["threshold"];
$fasta_text = $_POST["fasta_text"];

$myfile = fopen("/alldata/bblab_site/logs/hla_debugging.log", "a");
fwrite($myfile, "Parameters:\n");
fwrite($myfile, "letter: " . $letter . "\n");
fwrite($myfile, "threshold: " . $threshold . "\n");
fwrite($myfile, "fasta_text: " . $fasta_text . "\n");
fclose($myfile);


$descriptors = array (
0 => array("pipe", "r"),
1 => array("file", $_SESSION["results"], "a"),
2 => array("file", $_SESSION["tech_errors"], "a"),
7 => array("file", $_SESSION["errors"], "a"),
8 => array("file", $_SESSION["details"], "a")
);


$descriptors = array (
0 => array("pipe", "r"),
1 => array("file", $_SESSION["results"], "a"),
2 => array("file", $_SESSION["tech_errors"], "a"),
7 => array("file", $_SESSION["errors"], "a"),
8 => array("file", $_SESSION["details"], "a")
);



if ($threshold >= 0) {
$cmd = sprintf("echo \"%s\" | %s %s -t %s %s &", $fasta_text, $ruby,
$script, $threshold, $letter);
} else {
$cmd = sprintf("echo \"%s\" | %s %s --threshold=\"-1\" %s &", $fasta_text, $ruby,
$script, $letter);
}
if ($threshold >= 0) {
$cmd = sprintf("echo \"%s\" | %s %s -t %s %s &", $fasta_text, $ruby,
$script, $threshold, $letter);
} else {
$cmd = sprintf("echo \"%s\" | %s %s --threshold=\"-1\" %s &", $fasta_text, $ruby,
$script, $letter);
}

$myfile = fopen("/alldata/bblab_site/logs/hla_debugging.log", "a");
fwrite($myfile, "Invoking Ruby.\n");
fwrite($myfile, "Ruby executable: " . $ruby . "\n");
fwrite($myfile, "script: " . $script . "\n");
fwrite($myfile, "command: " . $cmd . "\n");
fclose($myfile);

$process = proc_open($cmd, $descriptors, $pipes);
$process = proc_open($cmd, $descriptors, $pipes);

$myfile = fopen("/alldata/bblab_site/logs/hla_debugging.log", "a");
fwrite($myfile, "process: " . $process . "\n");
fclose($myfile);

$pstatus = proc_get_status($process);

$myfile = fopen("/alldata/bblab_site/logs/hla_debugging.log", "a");
fwrite($myfile, "pstatus: " . $pstatus . "\n");
fclose($myfile);

$_SESSION["pid"] = $pstatus["pid"];
fclose($pipes[0]);
proc_close($process);
$_SESSION["pid"] = $pstatus["pid"];

$myfile = fopen("/alldata/bblab_site/logs/hla_debugging.log", "a");
fwrite($myfile, "pid (?): " . $pstatus["pid"] . "\n");
fclose($myfile);

fclose($pipes[0]);
proc_close($process);

$myfile = fopen("/alldata/bblab_site/logs/hla_debugging.log", "a");
fwrite($myfile, "Done with Ruby.\n");
fclose($myfile);

$resfile = "/django/tools/hla_class/tmp/" . array_pop(explode("/", $_SESSION["results"]));
$detfile = "/django/tools/hla_class/tmp/" . array_pop(explode("/", $_SESSION["details"]));
$techerrfile = "/django/tools/hla_class/tmp/" . array_pop(explode("/", $_SESSION["tech_errors"]));
$errfile = "/django/tools/hla_class/tmp/" . array_pop(explode("/", $_SESSION["errors"]));
printf("%s\n%s\n%s\n%s", $resfile, $detfile, $techerrfile, $errfile);
$resfile = "/django/tools/hla_class/tmp/" . array_pop(explode("/", $_SESSION["results"]));
$detfile = "/django/tools/hla_class/tmp/" . array_pop(explode("/", $_SESSION["details"]));
$techerrfile = "/django/tools/hla_class/tmp/" . array_pop(explode("/", $_SESSION["tech_errors"]));
$errfile = "/django/tools/hla_class/tmp/" . array_pop(explode("/", $_SESSION["errors"]));
printf("%s\n%s\n%s\n%s", $resfile, $detfile, $techerrfile, $errfile);
?>
1 change: 1 addition & 0 deletions bblab.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ RUN wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc |
ENV R_BASE_VERSION 4.5.1

RUN apt-get install -q -y --no-install-recommends \
r-recommended=${R_BASE_VERSION}-* \
r-base=${R_BASE_VERSION}-* \
r-base-dev=${R_BASE_VERSION}-* \
r-base-core=${R_BASE_VERSION}-* \
Expand Down
8 changes: 8 additions & 0 deletions compose-template.env
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,11 @@ BBLAB_TOOL_ROOT=/alldata/bblab_site/tools/
BBLAB_TEMPLATE_ROOT=/alldata/bblab_site/templates/

PYTHONPATH=/alldata/bblab_site/tools

# Mounts for generated data (these have sensible defaults in the compose file already):
# BBLAB_LOGS=/srv/bblab_site/logs
# BBLAB_MEDIA=/srv/bblab_site/media
# BBLAB_GUAVA_LAYOUT_OUTPUT=/srv/bblab_site/guava_layout/output
# BBLAB_SEQUENCING_LAYOUT_OUTPUT=/srv/bblab_site/sequencing_layout/output
# BBLAB_MYSQL=/srv/bblab_site/mysql
# BBLAB_DB_DUMP=/srv/bblab_site/db_dump
19 changes: 10 additions & 9 deletions docker-compose-bblab.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:
dockerfile: bblab.dockerfile
target: bblab-site
image: cfe-lab/bblab-site:${BBLAB_IMAGE_TAG:?no image tag set}
env_file: .env-bblab
# env_file: .env-bblab
environment:
- SMTP_MAIL_SERVER=${SMTP_MAIL_SERVER:?no smtp server set}
- SMTP_MAIL_PORT=${SMTP_MAIL_PORT:?no smtp port set}
Expand All @@ -41,6 +41,7 @@ services:
- BBLAB_OP_PATH=${BBLAB_OP_PATH:?no op path set}
- BBLAB_TOOL_ROOT=${BBLAB_TOOL_ROOT:?no tool root dir set}
- BBLAB_TEMPLATE_ROOT=${BBLAB_TEMPLATE_ROOT:?no template root dir set}
- PYTHONPATH=${BBLAB_PYTHONPATH:-/alldata/bblab_site/tools}
depends_on:
- db
networks:
Expand All @@ -51,8 +52,8 @@ services:
# in this container. Apache will set the URL from
# BBLAB_WEB_ADDRESS (use "localhost" or your DNS)
# and Django will accept requests to that address
# ports:
# - "80:80/tcp"
ports:
- "8000:80/tcp"
command: /bin/sh -c "/usr/sbin/apachectl -D FOREGROUND"
labels:
- "traefik.enable=true"
Expand All @@ -63,10 +64,10 @@ services:
- "traefik.http.routers.bblab-site.service=bblab-site"
- "traefik.http.services.bblab-site.loadbalancer.server.port=80"
volumes:
- /srv/bblab_site/logs:/alldata/bblab_site/logs:rw
- /srv/bblab_site/media:/alldata/bblab_site/media
- /srv/bblab_site/tools/guava_layout/output:/alldata/bblab_site/tools/guava_layout/output
- /srv/bblab_site/tools/sequencing_layout/output:/alldata/bblab_site/tools/sequencing_layout/output
- ${BBLAB_LOGS:-/srv/bblab_site/logs}:/alldata/bblab_site/logs:rw
- ${BBLAB_MEDIA:-/srv/bblab_site/media}:/alldata/bblab_site/media
- ${BBLAB_GUAVA_LAYOUT_OUTPUT:-/srv/bblab_site/tools/guava_layout/output}:/alldata/bblab_site/tools/guava_layout/output
- ${BBLAB_SEQUENCING_LAYOUT_OUTPUT:-/srv/bblab_site/tools/sequencing_layout/output}:/alldata/bblab_site/tools/sequencing_layout/output

db:
image: mariadb:11.6
Expand All @@ -82,8 +83,8 @@ services:
- MYSQL_PASSWORD=${BBLAB_DB_PASSWORD:?no password set}
- MYSQL_INITDB_SKIP_TZINFO=1
volumes:
- /srv/bblab_site/mysql:/var/lib/mysql
- /srv/bblab_site/db_dump:/docker-entrypoint-initdb.d
- ${BBLAB_MYSQL:-/srv/bblab_site/mysql}:/var/lib/mysql
- ${BBLAB_DB_DUMP:-/srv/bblab_site/db_dump}:/docker-entrypoint-initdb.d

# traefik:
# image: "traefik:${TRAEFIK_IMAGE_TAG:-latest}"
Expand Down