project BLF > class TDaemonUtility > method GetDaemonExecutable
function returns character
Description
Get the name of the Progress executable to use to start the daemon.
The function will try to find the exeuctable named "DMN_"-<environment-indication>-<DaemonName>.exe. If it does not find it, it will try to copy the _progres.exe to this file.
Parameters
| icDaemonName | input | character | |
| icDLC | input | character | |
Internal usage
BLF
program code (program1/tdaemonutility.p)
assign vcAppServerIndication = entry(3,session:server-connection-id,":":U) no-error.
ASSIGN vcEnvIndication = "D_":U + (if vcAppServerIndication = "" or
vcAppServerIndication = ?
then ""
else vcAppServerIndication + "_":U)
vcProgress = icDLC + (if OPSYS = "UNIX":U then "/bin/_progres":U else "~\bin~\_progres.exe":U)
vcDaemonExe = icDaemonName + (if opsys = "UNIX":U then "" else ".exe":U)
vcSlash = (if opsys = "Win32":U then "~\":U else "/":U).
file-info:file-name = vcProgress.
if file-info:file-type = ?
then if opsys = "UNIX":U
then assign vcProgress = search("_progres":U)
icDLC = replace(vcProgress,"/_progres":U,"").
else assign vcProgress = search("_progres.exe":U)
icDLC = replace(vcProgress,"~\_progres.exe":U,"").
vcDaemonExecutable = icDLC + vcSlash + vcEnvIndication + vcDaemonExe.
file-info:file-name = vcDaemonExecutable.
vlCreate = (file-info:file-type = ?).
if OPSYS <> "UNIX":U
and file-info:file-type <> ?
then do:
assign vcFileVersion = string(file-info:file-mod-date) + string(file-info:file-mod-time).
file-info:file-name = vcProgress no-error.
if vcFileVersion <> string(file-info:file-mod-date) + string(file-info:file-mod-time)
then assign vlCreate = yes.
end.
if vlCreate
then do :
assign vcDir = vcProgress
entry(num-entries(vcDir,vcSlash),vcDir,vcSlash) = "".
if opsys = "UNIX":U
then os-command value("ln -s ":U + vcProgress + " ":U + vcDir + vcEnvIndication + vcDaemonExe).
else do:
/* first try to create a symbolic link */
os-command value("mklink ~"" + vcDir + vcEnvIndication + vcDaemonExe + "~" ~"" + vcProgress + "~"").
/* if symbolic link fails (older windows version, no NTFS, no permission) do a copy */
file-info:file-name = vcDir + vcEnvIndication + vcDaemonExe.
if file-info:file-type = ?
then os-copy value(vcProgress) VALUE(vcDir + vcEnvIndication + vcDaemonExe).
end.
/* Check if copy was successfull. Do not use os-error as it is always zero. */
file-info:file-name = vcDir + vcEnvIndication + vcDaemonExe.
if file-info:file-type = ?
then vcDaemonExecutable = vcProgress.
else vcDaemonExecutable = vcDir + vcEnvIndication + vcDaemonExe.
end.
return vcDaemonExecutable.