diff --git a/plugins/FileMonitor/filemonitor.js b/plugins/FileMonitor/filemonitor.js index ac16ef5..7aaf61f 100644 --- a/plugins/FileMonitor/filemonitor.js +++ b/plugins/FileMonitor/filemonitor.js @@ -16,6 +16,8 @@ const { Link, NavLink, } = PluginApi.libraries.ReactRouterDOM; var iconToUse = faFileCircleXmark; var FileMonitorRunningStatusStr = ""; + var IS_DOCKER = false; + var DockerWarning = null; function RunPluginFileMonitor(Mode, ActionID = 0, DataType = "text", Async = false) { console.log("Mode = " + Mode); const AjaxData = $.ajax({method: "POST", url: "/graphql", contentType: "application/json", dataType: DataType, cache: Async, async: Async, @@ -33,6 +35,13 @@ iconToUse = faFileCircleXmark; FileMonitorRunningStatusStr = "FileMonitor is NOT running!!!"; } + if (result.indexOf("IS_DOCKER:'True'") > 0){ + IS_DOCKER = true; + DockerWarning = React.createElement("div", null, + React.createElement("h4", null, "Must run FileMonitor on host machine. Do not run directly in Docker! For more information see following link:"), + React.createElement("a", {href: "https://github.com/David-Maisonave/Axter-Stash/tree/main/plugins/FileMonitor#Docker", style:{color:"pink"}, target:"_blank"}, "https://github.com/David-Maisonave/Axter-Stash/tree/main/plugins/FileMonitor#Docker")); + console.log("FileMonitor must run on host machine. Do NOT run FileMonitor directly in Docker. See following link for more details.\n https://github.com/David-Maisonave/Axter-Stash/tree/main/plugins/FileMonitor#Docker"); + } console.log(FileMonitorRunningStatusStr); if (ActionID == 0) PluginApi.patch.before("MainNavBar.UtilityItems", function (props) { @@ -57,15 +66,6 @@ $("body").css("cursor", "default"); } }); - // if (Async == true) - // return true; - // if (DataType == "text") - // { - // console.log(AjaxData.responseText); - // return AjaxData.responseText; - // } - // console.log(AjaxData.responseJSON); - // return JSON.parse(AjaxData.responseJSON.data.runPluginOperation.replaceAll("'", "\"")); } RunPluginFileMonitor("getFileMonitorRunningStatus"); const HomePage = () => { @@ -76,7 +76,8 @@ MyHeader, React.createElement("p", null), React.createElement("p", null), - React.createElement("h4", null, FileMonitorRunningStatusStr) + React.createElement("h4", null, FileMonitorRunningStatusStr), + DockerWarning )); }; PluginApi.register.route("/FileMonitor", HomePage); diff --git a/plugins/FileMonitor/filemonitor.py b/plugins/FileMonitor/filemonitor.py index cc5a09a..04fdd99 100644 --- a/plugins/FileMonitor/filemonitor.py +++ b/plugins/FileMonitor/filemonitor.py @@ -143,7 +143,7 @@ if not parse_args.docker == None and len(parse_args.docker) > 0: tb = traceback.format_exc() stash.Error(f"Exception while parsing Docker file {parse_args.docker}; Error: {e}\nTraceBack={tb}") -if stash.IS_DOCKER: +if stash.IS_DOCKER and stash.PLUGIN_TASK_NAME != "stop_library_monitor" and not parse_args.stop and stash.PLUGIN_TASK_NAME != "getFileMonitorRunningStatus": stash.Error("You are running this script from within Docker. This is NOT supported. Run this script in the host machine instead.") stash.Warn("For more information on running FileMonitor on host machine see following link:\n https://github.com/David-Maisonave/Axter-Stash/tree/main/plugins/FileMonitor#Docker") stash.Warn("Performing early exit because FileMonitor has to run on the host machine, and can NOT run on Docker directly.") @@ -937,7 +937,7 @@ def getFileMonitorRunningStatus(): pass stash.Log("FileMonitor is NOT running!!!") stash.Log(f"{stash.PLUGIN_TASK_NAME} complete") - sys.stdout.write("{" + f"{stash.PLUGIN_TASK_NAME} : 'complete', FileMonitorStatus:'{FileMonitorStatus}'" + "}") + sys.stdout.write("{" + f"{stash.PLUGIN_TASK_NAME} : 'complete', FileMonitorStatus:'{FileMonitorStatus}', IS_DOCKER:'{stash.IS_DOCKER}'" + "}") try: if parse_args.stop or parse_args.restart or stash.PLUGIN_TASK_NAME == "stop_library_monitor":