Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

Commit

Permalink
Run FBP program in repo instead of copying stucture to tmp
Browse files Browse the repository at this point in the history
The running method was focused in building a run environment before running
the project.

When DECLARE was created, Soletta Dev-App started creating a
building environment wrongly when DECLARE was used with relative PATH.

With this patch Soletta Dev-App will run the project directly in the
right PATH of the repo, making DECLARE working with Relative paths.

Fixes the issue: Devapp wasn't finding the external FBP when using DECLARE in a
relative path.
  • Loading branch information
Bruno Bottazzini committed Mar 31, 2016
1 parent 3aa8ba5 commit 48679a7
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 107 deletions.
61 changes: 41 additions & 20 deletions client/js/controllers/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
function ($compile, $scope, $http, $interval, $document, broadcastService,
FetchFileFactory, usSpinnerService, svConf) {
var isRunningSyntax = false;
var runningFBP;
var promiseCheckSyntax;
var promiseServiceStatus;
var promiseRunViewer;
Expand Down Expand Up @@ -290,7 +291,7 @@
$http.get('/api/journald',
{
params: {
"unit_name": "fbp-runner@"
"unit_path": runningFBP,
}
}).success(function(data) {
$scope.RunViewer = data;
Expand All @@ -302,11 +303,14 @@
$scope.run = function() {
if ($scope.isServiceRunning) {
//Post stop service
$http.post('/api/fbp/stop').success(function(data) {
if (data == 1) {
alert("FBP Service failed to stop");
}
});
$http.post('/api/fbp/stop',
{
params: {"fbp_path": runningFBP}
}).success(function(data) {
if (data == 1) {
alert("FBP Service failed to stop");
}
});
} else if ($scope.fbpType === true && $scope.buttonSyncDisabled === false) {
var fbpCode = editor.getSession().getValue();
var fbpName = $scope.fileName;
Expand All @@ -315,14 +319,19 @@
if (conf === "none") {
conf = null;
}
if (!filePath) {
filePath = "/tmp/cached.fbp";
}
$http.post('/api/fbp/run',
{params: {
"fbp_name": fbpName,
"fbp_path": filePath,
"code": fbpCode,
"conf": conf
}
}).success(function(data) {
if (data == 0) {
runningFBP = filePath;
$scope.openRunDialog();
} else {
alert("FBP Failed to run");
Expand All @@ -344,11 +353,15 @@
window.onbeforeunload = onBeforeUnload_Handler;
function onBeforeUnload_Handler() {
if ($scope.isServiceRunning) {
$http.post('/api/fbp/stop').success(function(data) {
if (data == 1) {
alert("FBP Service failed to stop. Process should be stopped manually");
}
});
$http.post('/api/fbp/stop',
{params: {
"fbp_path": runningFBP
}
}).success(function(data) {
if (data == 1) {
alert("FBP Service failed to stop. Process should be stopped manually");
}
});
}

if ($scope.shouldSave === true) {
Expand All @@ -366,15 +379,19 @@
if (conf === "none") {
conf = null;
}
if (!filePath) {
filePath = "/tmp/cached.fbp";
}
$http.get('/api/check/fbp',
{params: {
"fbp_path": filePath,
"code": fbpCode,
"conf": conf
}
}).success(function(data) {
$scope.FBPSyntax = data.trim();
var errorline = data.match(/fbp_syntax\.fbp:[0-9]+:[0-9]+/g);
var errorDesc = data.split(/fbp_syntax\.fbp:[0-9]+:[0-9]+/g);
var errorline = data.match(/.+\.fbp:[0-9]+:[0-9]+/g);
var errorDesc = data.split(/.+\.fbp:[0-9]+:[0-9]+/g);
editor.getSession().removeMarker(markId);
editor.getSession().clearAnnotations();
if (errorline) {
Expand Down Expand Up @@ -651,23 +668,27 @@
};

$scope.getServiceStatus = function () {
$http.get('/api/service/status',
{params: {
"service": "fbp-runner.service"
}
if (runningFBP) {
$http.get('/api/service/status',
{
params: { "fbp_path": runningFBP }
}).success(function(data) {
$scope.startServiceStatus();
$scope.ServiceStatus = data.trim();
if ($scope.ServiceStatus.indexOf("active (running)") > -1) {
$scope.isServiceRunning = true;
} else {
$scope.isServiceRunning = false;
}
$scope.ServiceStatus = $scope.ServiceStatus.replace(/since.*;/,"");
if (runningFBP) {
$scope.ServiceStatus = $scope.ServiceStatus.replace(/since.*;/,"");
} else {
$scope.ServiceStatus = runningFBP + " - " + $scope.ServiceStatus.replace(/since.*;/,"");
}
}).error(function(){
$scope.startServiceStatus();
$scope.ServiceStatus = "Failed to get service information";
});
}
$scope.startServiceStatus();
};

$scope.refreshTree = function () {
Expand Down
8 changes: 4 additions & 4 deletions scripts/fbp-runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ export SOL_LOG_PRINT_FUNCTION="journal"
if [ $# -eq 3 ]; then
export SOL_FLOW_MODULE_RESOLVER_CONFFILE=$3
fi
USER_TMP="$2"
echo "USER_TMP="$USER_TMP
SERVICE="fbp-runner@"$(systemd-escape $USER_TMP)
FBP_PATH="$2"
echo "FBP_PATH="$FBP_PATH
SERVICE="fbp-runner@"$(systemd-escape $FBP_PATH)
echo "SERVICE="$SERVICE
SCRIPT="$USER_TMP/fbp_runner.fbp"
SCRIPT="$FBP_PATH"
systemctl stop $SERVICE
if [ $1 == "start" ]; then
syntax=`sol-fbp-runner -c $SCRIPT | grep OK`
Expand Down
Loading

0 comments on commit 48679a7

Please sign in to comment.