There was an article posted on a private blog 10 years ago covering the topic - https://lansablog.wordpress.com/2012/03 ... s-service/ and a C# project. Unfortunately the code attachment link links to a dead site.
In the last decade nssm - https://nssm.cc/usage has been used as the poor man's method of setting up services, although some virus scanners don't like it, and I have used it outside of LANSA.
The scenario I have is a WIndows application deployment that starts a function from .BAT files which continuously runs and processes streams of data into SQL Server and updating an IBMi backend. The current issue with manually running the function using .BAT files containing X_RUN switches is that the Function may start running more than once, and a service will improve memory management and ensure the LANSA batch function runs only once at application startup.
What techniques are folks using to run LANSA batch functions as windows services in 2023 with LANSA V14SP2 or V15 ?
Running a LANSA background Function as a Windows Service
Re: Running a LANSA background Function as a Windows Service
Patrick,
Portalize does something like:
during its installation...
this actually creates a 'scheduled task' that runs on startup.
you can check out the xml file for additional settings....
the *initial* function just does a SUBMIT function which uses #XPRIM_OSUtil.ThreadSleep Milliseconds(#LoopDelay)
to control its loop....
B.
Portalize does something like:
Code: Select all
powershell -command "Start-Process -filepath 'cmd.exe' -ArgumentList '/C schtasks /Create /ru pcxuser /rp pcxuser /tn StartPortalBackgroundProcesses /xml C:\Progra~2\Visual~1\Internal\X_WIN95\X_LANSA\x_BPF\portal\plugins\StartPortalProcesses_installed.xml /F' -WindowStyle Maximized -Verb RunAs"
this actually creates a 'scheduled task' that runs on startup.
you can check out the xml file for additional settings....
the *initial* function just does a SUBMIT function which uses #XPRIM_OSUtil.ThreadSleep Milliseconds(#LoopDelay)
to control its loop....
B.
Re: Running a LANSA background Function as a Windows Service
Perhaps this will help:
https://stackoverflow.com/questions/358 ... executable
Create the Windows service and run the X_RUN.EXE with appropriate parameter settings?
https://stackoverflow.com/questions/358 ... executable
Create the Windows service and run the X_RUN.EXE with appropriate parameter settings?
-
René Houba
- Posts: 220
- Joined: Thu Nov 26, 2015 7:03 am
Re: Running a LANSA background Function as a Windows Service
As an example.....
For a customer that creates a lot of LANSA reports in Windows, I created a task in the Windows job scheduler that activates a powerscript that deletes reports older than xx days.
The complete argument:
-File C:\LANSA_Scripts\delete_Lansa_reports.ps1 -partition PRD
The script:
For a customer that creates a lot of LANSA reports in Windows, I created a task in the Windows job scheduler that activates a powerscript that deletes reports older than xx days.
The complete argument:
-File C:\LANSA_Scripts\delete_Lansa_reports.ps1 -partition PRD
The script:
-
René Houba
- Posts: 220
- Joined: Thu Nov 26, 2015 7:03 am
Re: Running a LANSA background Function as a Windows Service
Another example where a Windows scheduled task activates a LANSA program, doing a REST-API call to an iSeries database.....
Activates LANSA's x_start.exe: The content of APICALL.lvp:
Activates LANSA's x_start.exe: The content of APICALL.lvp: