Included in FoxCli
Windows services written in Visual FoxPro.
Do you have a PC with a VFP exe and a Timer that somebody has to leave open to import orders, send the pending emails or run the closing of every night? FoxService turns it into a Windows service: it starts with the computer, keeps running even if nobody logs in, comes back up if it falls and writes to the Event Log. You only write the logic, in VFP.
FoxService is part of the FoxCli installer and license: it is not bought separately. Without a license it runs in full, without limits, and the service says when it starts that it is in evaluation.
A class in src\main.prg, and every public method is a job. The *!* line above it says when it runs. It is the sample every new project comes with: an importer of orders that already works the first time you run it.
DEFINE CLASS OrdersService AS FoxServiceBase OF foxservice.prg OLEPUBLIC
*-- Every CSV that arrives in inbox\: its orders into the table.
*!* @watch inbox *.csv
PROCEDURE ImportOrders(tcPath, tcChange)
...
ENDPROC
*-- Every 30 seconds: how many orders are waiting.
*!* @every 30s
PROCEDURE CountPending
LOCAL lnPending
THIS.OpenOrders()
COUNT FOR status == "P" TO lnPending
THIS.Log("Pending orders: " + TRANSFORM(lnPending))
ENDPROC
*-- Every night: the summary of the day.
*!* @daily 23:55
PROCEDURE DailySummary
THIS.WriteSummary()
ENDPROC
ENDDEFINEThe foxservice CLI does the same without the IDE, and on the server the service's exe is enough. Its commands are also tools for an AI agent (foxservice_new, foxservice_build, foxservice_install…) through FoxStack, for free.
foxservice new --name orders --folder C:\svc
foxservice build --folder C:\svc\orders
foxservice run --folder C:\svc\orders --for 1m
orders.exe install --account "NT SERVICE\orders" --startA service has no screen and no user: no forms, no MESSAGEBOX, no printing to a printer. Code that tries does not hang: the job fails at once, and the log says the line and the reason. A VFP error reaches the log by itself, with its number and its line, and the service keeps running, so jobs are written without TRY ... CATCH.
To program, Visual FoxPro 9 or 32-bit VFP Advanced 10.2, and FoxForge, which is installed with FoxCli. On the server, Windows with the 32-bit .NET 10 runtime: no Visual FoxPro, because its runtime travels in the service's folder, and no license, because the license belongs to whoever builds.
The full guide comes with FoxForge, in Help > FoxService guide, in English, Spanish and German. It starts with the first steps: the importer of orders, explained job by job.
No. You write a VFP class. The service's exe, which FoxService leaves in the dist\ folder next to your DLL, takes care of installing, starting and stopping it, of the schedules and of the Event Log. From FoxForge you do not even need to open a console: Install, Start and Stop are buttons.
FoxServer answers HTTP requests: somebody calls and your code answers. FoxCore runs tasks in the background inside your application, so that its screen does not freeze meanwhile. FoxService needs no application open: it works on its own, when its time comes, at a time of day, every so often or when a file arrives. They can be used together, each one with its license.
The FoxCli one: FoxService comes with it and with its installer. The license belongs to whoever builds; the servers where the service runs need none. Without a license everything runs, without limits, and the service says once when it starts that it is in evaluation.
The one it comes with is the system account (LocalSystem): it reaches any folder of the computer, like the desktop program it replaces. For a network folder, an account of the service's own (NT SERVICE\name) or a Windows or domain user; the password is asked for when installing, without echo.
With 1, the value it comes with, jobs queue up: if an import takes ten minutes, the one that runs every 30 seconds waits and its turns are skipped meanwhile. With 2 or more, a long job does not delay the short ones. Each one is a separate VFP, with its variables and its open tables.
A VFP error reaches the log with its number and its line, the job counts as failed and the service goes on. A job that goes past its maximum time (one hour, unless you say otherwise) is told to stop; if it does not come back, the service restarts itself within seconds. Three times in a row, and that job is no longer scheduled until you look at it.
To a printer, no: a service has no user session and no printers. The job that tries fails at once, and the log says so.
Yes, with the reports runtime: ReportToPdf takes the pages of an .frx and the service composes the PDF. The pages are images at 300 dpi, so the text cannot be selected or searched, and with that runtime one job runs at a time.
Yes, with 32-bit VFP Advanced 10.2. Two differences: there is no reports runtime, and it stays at one job at a time.
Yes. The commands of the foxservice CLI are MCP tools through FoxStack, for free. Installing needs an administrator console: if the agent does not have one, it gets the exact command for a person to run.
If something does not add up, write to me: soporte@irwinrodriguez.dev