'Folder monitor' is found in the 'Start' category of workflow nodes.
A folder monitor node looks for new files arriving in a specified folder (or directory). It can monitor folders, FTP sites, SFTP sites, or external services.
A folder monitor comes pre-packed with a script that generates an info block, for use by downstream scripting nodes, containing:
for both the source file and the destination file (after the file has been moved b the folder monitor. Other fields could be added to this infoblock although this is often not required.
The contents of this infob lock typically look like this:
As with other Busby workflow nodes a range of configuration parameters are available, the main ones being the location of the folder to monitor and the destination folder to move files to once they have been detected. The coniguration pane looks like this:
Field | Description |
---|---|
Display name | Name to display in the workflow diagram |
State ID | ID to use when referring to this state in scripts |
Script step service | The script step used to run this folder monitor. This refers to the actual process that is monitoring the folder. All locations are from the perspective of this script step. |
Job timeout minutes | Timeout for the script to run after a file has been monitored. |
Location type | One of Folder, FTP, SFTP, or External. |
Location to monitor | The location to monitor. This refers to the specific folder, FTP etc. Using a location means it is possible for different deployments to monitor different places, whilst keeping the underlying configuration the same. If no location is selected then the Folder to monitor is used directly. |
Folder to monitor | The folder within the location to monitor. For example if the location refers to the folder /mnt and the folder to monitor is tst, then the folder monitor will monitor /mnt/tst. |
Match file (as glob) | Select which files should be monitored based on a glob pattern |
Keep files in monitor folder | Whether to keep the monitored files in their source folder, or to move them to a destination folder. If keeping files in the source folder a database of collected files is created, this means that a redelivery of a previously collected file will not trigger the folder monitor again. |
Scan subfolders | Whether to monitor sub folders or not |
Folder mode | Whether to only monitor for folder creation, rather than file drops. |
Move file to this location | If the keep files in monitor folder is false, then on a file arrival move the files to this location. The moved files are prepended with an ISO8601 date string, this allows for the same file to be delivered multiple times. |
Move file to this folder | Used in conjunction with Move file to this location above. This folder is joined with the location to give the exact place the destination file is created. |
Delay between running decision scripts | If multiple files are dropped at once then the state decision scripts that are called will be delayed by this amount. This can normally be left unset, unless there is an expectation that a lot of files will be dropped in one go. |
Polling interval | In order to determine that a file is complete a settling period is used. This checks that the file size of the incoming file is not changing (and not zero). The polling interval is the gap between checks, three consecutive non-changing checks indicate the file has successfully arrived. |
State decision scripts | The script to run after a job has been monitored. In general the output of this script should be the creation of a workflow job, the default script adds in a Folder monitor info block, which can then be used in downstream processing. The exit of the script step should always be to the initial state of the workflow, or be excluded completely if no job is created. |
Once a job has been created the next step of the workflow is likely going to have to read the file and do some processing. Often this will be a script step that carries out this processing.
The script below shows an example of how this might work. First the file path is extracted from the folder monitor info block, and then the file is read.
const fullPath = busby.stateStore.getFolderMonitorInfo("titlesXml").getDestinationPath()
const xml = busby.file.read(fullPath, { encoding: "utf-8" })
Previous: Alarm monitor || Next: Job create form
Index of: Workflow Nodes
Back to: Configuration Editor