These are three tools specially useful for automatic recovery after crashes, power cycles, and so on:


1 - Worflows can be launched with a "-A" parameter to load and execute a workflows file (.mwf)


2 - The Operating System can be told to launch a particular program at startup (for example the Mistika Workflows with the -A parameter ), also restarting the same task it if it dies.


3 - The Workflows "Watcher" node provides properties to retry files being processed at crash time (cont.prev.execution / Number Of Tries)


Practgical Example (on Windows): Let's suppose Worflows is installed using the default paths, and we have our workflows file stored here:


C:\My Workflows\My Workflow.mwf


Then the command that we need is this one:


"C:\Program Files\SGO Apps\Mistika Workflows\bin\workflows.exe -A "C:\My Workflows\My Workflow.mwf"


We can put this command in a scheduled task of the operating system, so that it will force to be always running, if it crashes or if the user logout and login again. 


Before we continue, open a cmd console and execute the above command manually. You should see that it will open Mistika Workflows, then it will load the .mwf file and it will execute its workfows automatically.


Once you confirm that the command line does what you want let's create an operating system task that will load it automatically after the user log on, and then if will check every 5 minutes if it still working or if it crashed, and if it crashed  (or if somebody closed it)  it will launch it again automatically:

 

1 - In the windows search field type:  Task Scheduler (and press enter)


2 - Click  Actions -> Create Task  (make sure you click on  "Create Task" , not "Create basic task" which is not enough or our purposes).  A new dialog "Create Task" will open:


3 - Type a name for the task, for example: "Relaunch Workflows on login and if it crashes"


4 - Activate "Run only when user is logged on"  (this is important, as Workflows can not run without a graphics session).  


5 - Click on "Configure for:" and select your Windows version (or the most similar to it)


6 - Select Triggers -> "New", and select these options: 

 * Begin the task -> At log on

 * Specific user (your worflows user should be selected)

 * Advanced Settings:

   Repeat task every -> 5 minutes

   For a duration of -> indefinitely

   Deactivate "Stop all running tasks  at end of repetition duration"

   Deactivate "Stop task if it runs longer than"

   Deactivate "Activate" and "Expire"


7 - Select Actions -> "New", then select these options (according to the above example):

Action -> Start a program

Program/scrtipt:  "C:\Program Files\SGO Apps\Mistika Workflows\bin\workflows.exe" 

Add arguments: -A "C:\My Workflows\My Workflow.mwf"


(Don't forget the double quotes in those commands, they are important when there are spaces)


8 - Now in the "Conditions" tab:

Deactivate "Start the task only if the computer is idle for"

Deactivate  "Start the task only if the computer is on AC power"

Activate "Wake the computer to run this task"


9 - In the settings tab:

Activate "If the task fails, restart every" and select "1 minute" 

Attempt to restart up to:  10 times (logically if it fails more times in a row it does not make sense to try harder, something else must be wrong...)

Deactivate "Stop the task if it runs longer than"

Deactivate "if the running task does not end..."

Deactivate "if the task is not scheduled to run again, delete it after"


Select  "If the task is already running, then the following rule applies:

 "Do not start a new instance"


10 - Press Ok to finish task creation.


The scheduled task will appear in the task list. It is ready to be tested and it can also be executed manually, but it is not yet active:  Last thing we need to do is to logout and login from our user, because we selected "At Log on"  as the trigger.


 To confirm that it works:


- Logout and login. You should see how Workflows will open, it will load the .mwf file, and it will execute all its workflows automatically.


- Now exit or kill the Workflows application, for example using the Task Manager (to simulate a crash)


- After maximum 5 minutes you should see how it is launched again.


Note: If you need to stop the automatic task for a while, remember that you can always open the Task Scheduler, select the task and disable it temporally.


Watcher node configuration:


There are two properties that will let us to decide what to do after a crash:


cont.prev.execution (Continue Previous Executions) / Number Of Tries: These properties are useful for reacting to software or system crashes. It permits to decide what to do with the files that were being processed at the crash time:

When cont.prev.execution is active, on next execution the Watcher node will retry any files that started a workflow in a previous occasion but didn't complete it (typically due to a crash, blackout, or similar situation).

The Number Of Tries property permits to establish a limit of retries, so if a particular file is crashing workflows every time then it will be skipped after that number of retries.

If cont.prev.execution is disabled then any previous files with uncomplete workflow executions will be simply ignored, and the watcher will wait for new incoming files.