Shutting Down a Running Robo-FTP Service |
Top Previous Next |
Using the Stop/Remove Service function of the Service Installer or Dashboard has been mentioned elsewhere as the proper way of shutting down a Robo-FTP Service. This always works but it does not always result in a clean and orderly termination when a communications session is in progress. This requires some special attention during the creation of script files used by the Robo-FTP Service.
The idea is to have the main service script regularly monitor for the presence of a special shutdown script. If it becomes necessary to terminate the service, manually copy the shutdown script to a designated location, the Robo-FTP Service detects its presence and transfers control to it using the CHAIN script command at an appropriate time. Then the stop may be issued from the Service Installer or Enterprise Dashboard.
In this example, a script named "shutdown.s" contains the following:
; Robo-FTP Service shutdown script
Your production script file(s) are obviously application dependent, but any script used with a Robo-FTP Service should either continuously loop looking for something to do, or sleep between predetermined periods of activity. The GETNEXTFILE command is often used to monitor a folder for a file to transmit, so we’ll use this construct to demonstrate how to use a shutdown script.
;; Robo-FTP Service production script :top ;; look for any file in current folder GETNEXTFILE "*" /timeout=10 ;; branch if 10 seconds elapsed IFERROR $ERROR_WAIT_TIMED_OUT goto nofile ;; branch on any other error IFERROR goto some_error ;; connect with remote system ;; send the file we just found SENDFILE %nextfile ;; disconnect from remote DISCONNECT ;; loop back to next file to send GOTO top :no_file ;; branch if no shutdown script IFNFILE "shutdown.s" goto top ;; transfer to shutdown script CHAIN "shutdown.s" :some_error . . .
This is one of many ways to have the Robo-FTP service execute an EXIT and any other necessary clean-up commands prior to having the service stopped. This permits the Robo-FTP Service to perform an orderly termination of a Robo-FTP communication session.
See also: Programming Service Scripts, Installing Robo-FTP as a Service |