Shutting Down a Running Robo-FTP Service

Top  Previous  Next

 

Using the Stop/Remove Service function of SrvInstaller 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 script regularly monitor for the presence of a special shutdown script. If it becomes necessary to terminate the Robo-FTP Service, this shutdown script would be copied to a designated folder, 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 SrvInstaller.

 

The shutdown script, we’ll name the file "shutdown.s", might look like the following:

 

; Robo-FTP Service shutdown script

DISCONNECT

EXIT

 

Your production script file(s) are obviously application dependent, but any script used with a Robo-FTP Service should continuously loop looking for something to do. 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

FTPLOGON

;; 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

. . .

 

Obviously there are other ways to skin this cat, but the important thing is to have the Robo-FTP Service execute a DISCONNECT and/or EXIT commands prior having the Service stopped using SrvInstaller. This permits the Robo-FTP Service to perform an orderly disconnect (if necessary) and termination of a Robo-FTP communication session.