Fixed the _already running_ issue
@@ -101,6 +101,16 @@ foglamp_start() {
# Start the Storage Plugin for the Data
"$FOGLAMP_ROOT/scripts/storage/storage_data" start
+ result=`foglamp_status "silent"`
+ case "$result" in
+
+ "0")
+ #FogLAMP already running
+ foglamp_log "info" "FogLAMP is already running." "all" "pretty"
+ ;;
+
+ "2")
+ #FogLAMP not running
PYTHONPATH=${FOGLAMP_ROOT}/python
export PYTHONPATH
if [[ -e "$PYTHONPATH/foglamp/services/core/__main__.py" ]]; then
@@ -110,6 +120,13 @@ foglamp_start() {
foglamp_log "err" "FogLAMP core not found." "all" "pretty"
exit 1
fi
+ ;;
+
+ *)
+ foglamp_log "err" "Unknown return status." "all"
+ exit 1
+ ;;
+ esac
}
@@ -162,7 +179,11 @@ foglamp_status() {
result=`curl -s http://localhost:8081/foglamp/ping || true`
case "$result" in
+
*uptime*)
+ if [[ "$1" == "silent" ]]; then
+ echo "0"
+ else
tot_sec=`echo $result | cut -d":" -f2 | cut -d"." -f1`
foglamp_log "info" "FogLAMP running." "outonly" "pretty"
foglamp_log "info" "FogLAMP uptime: $tot_sec seconds." "outonly" "pretty"
@@ -179,13 +200,22 @@ foglamp_status() {
# Show Tasks
foglamp_log "info" "=== FogLAMP tasks:" "outonly" "pretty"
ps -ef | grep -o 'python3 -m foglamp.tasks.*' | grep -o 'foglamp.tasks.*' | grep -v 'foglamp.tasks\.\*' || true
-
- # Enable exit on error
- #set -e
-
+ fi
;;
*)
+ if [[ `ps -ef | grep -c 'python3 -m foglamp.services.core'` -gt 1 ]]; then
+ if [[ "$1" == "silent" ]]; then
+ echo "0"
+ else
+ foglamp_log "info" "FogLAMP starting." "outonly" "pretty"
+ fi
+ else
+ if [[ "$1" == "silent" ]]; then
+ echo "2"
+ else
foglamp_log "info" "FogLAMP not running." "outonly" "pretty"
+ fi
+ fi
;;
esac
}
