From 884c1ea05f7c1cee7e7aa96d0e82b14095638a0b Mon Sep 17 00:00:00 2001 From: Sebastian Rieger Date: Mon, 6 Mar 2017 17:46:18 +0100 Subject: [PATCH] added some install documentation, added debug output for cron job --- README.md | 26 +++++++++++++++++++++++++- api/cron.php | 5 +++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 024da11..1eba926 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,33 @@ Setup instructions * make sure bower, composer and npm are available on command line +** e.g. for Ubuntu 16.04 (VIRL 1.3.156 host): +*** "sudo apt-get install npm" +*** "sudo apt-get install nodejs-legacy" +*** "sudo npm install -g bower" +*** "sudo apt install libapache2-mod-php7.0 php7.0-sqlite3 php-xml php-curl" +*** "curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer" + * run **npm update** in virl-scheduler root directory (only if you want to test in devmodes, apache is enough otherwise) * run **bower update** in virl-scheduler root directory, afterwards verify **bower_components** directory was created * run **composer update** in virl-scheduler root directory, afterwards verify **vendor** directory was created + * configure apache to use **virl-scheduler** and **index.html** as webroot (make sure rewrite engine is on and .htaccess files are parsed by apache) +** e.g. for Ubuntu 16.04 (VIRL 1.3.156 host): +*** copy virl-scheduler to your webroot: "sudo cp -a virl-scheduler /var/www/html/" +*** add "ProxyPass /virl-scheduler !" to the ProxyPass directives in **/etc/apache2/sites-available/000-default.conf** +*** allow .htaccess in virl-scheduler api directory, e.g., by appending the following lines to **/etc/apache2/sites-available/000-default.conf** + + AllowOverride All + +*** give the Apache2 process write permissions to the sqlite3 db by running "sudo chown www-data:www-data api/db.sqlite3" and "sudo chown www-data:www-data api" in the virl-scheduler directory +*** run **service apache2 restart** + +* Change hostname for **VIRLRestangular factory** in **app/topologyManager.js** and **api/cron.php** to your VIRL-API-Hostname or IP-Address. + +* Add a cron job to run the scheduler, e.g., every five minutes and start planned simulations +** e.g. for Ubuntu 16.04 (VIRL 1.3.156 host): +*** "sudo crontab -e" add "*/5 * * * * /usr/bin/curl -o /var/log/virl-scheduler-cron.log http://localhost/virl-scheduler/api/cron.php" at the end of the file +* Have fun using the scheduler to start VIRL simulations automatically, by accessing /virl-scheduler on your VIRL host. Login using a VIRL username and password, be sure to add a Session name (simulation name) and a VIRL topology (XML source of a topology file) -Change hostname for **VIRLRestangular factory** in **app/topologyManager.js** to your VIRL-API-Hostname or IP-Address. +* output of the cron job can be seen in **/var/log/virl-scheduler-cron.log** or by accessing http:///virl-scheduler/api/cron.php" manually in your browser \ No newline at end of file diff --git a/api/cron.php b/api/cron.php index 598da94..7cd4d2d 100644 --- a/api/cron.php +++ b/api/cron.php @@ -14,7 +14,7 @@ $sims = $query->fetchAll(); foreach ($sims as $sim){ - $url = "192.168.76.210:19399/simengine/rest/launch"; + $url = "192.168.76.211:19399/simengine/rest/launch"; echo "Attempting to start simulation called ".$sim["sessionname"]."
"; if ($sim["status"] == "scheduled") $query = $pdo->prepare("UPDATE simulations SET status = 'Done' WHERE id = ?"); @@ -42,6 +42,7 @@ foreach ($sims as $sim){ var_dump($curlinfo); $response = json_decode($output,true); $return = array("response"=>$response,"httpinfo"=>$curlinfo); - + var_dump($response); + curl_close($ch); } \ No newline at end of file