Shutting Down a Running FileLink Service

Top  Previous  Next

 

Using the Stop/Remove Service function of SrvInstaller has been mentioned elsewhere as the proper way of shutting down a FileLink 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 FileLink 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 FileLink Service, this shutdown script would be copied to a designated folder, the FileLink 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:

 

; FileLink Service shutdown script

DISCONNECT

EXIT Script_Commands_(QUIT)CONNECT

 

Your production script file(s) are obviously application dependent, but any script used with a FileLink 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.

 

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

CONNECT                    

;; 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 FileLink Service execute a DISCONNECT and/or EXIT commands prior having the Service stopped using SrvInstaller. This permits the FileLink Service to perform an orderly disconnect (if necessary) and termination of a FileLink communication session.