Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.

How to uniquely identify worker/engine instances?

I’m experimenting with a custom logger for our OI HTTP server and want each engine to append its log entries to its own file.

I’m struggling to find a reliable way to identify the current engine so I can name the log files accordingly.

I initially tried using the engine’s PID, but since engines are despawned and respawned depending on traffic, the PID isn’t stable and ends up referring to different processes over time.

Would it be possible to use the port number of the engine handling a given HTTP request as an identifier? Or is there a better approach for uniquely identifying each engine instance?

Comments

  • Copilot say to try this:

    EngineID = Get_Status("ENGINE_ID")
    or
    EngineID = Get_Status("ENGINE")
  • Angelo - The port only applies to the engine server itself. All engines managed by the engine server communicate through a named pipe. You can get this information if you want, but you seem to be looking for a static way to identify each engine so your logs matched up. Do I understand that correctly?

    I think you have already stated the obvious: because the engines despawn and respawn as needed, nothing transfers over to newly spawned engines. They will get a new named pipe, new PID, etc. Let me know if I misunderstood you.
  • edited 9:17PM
    Oh no, I do not need anything to persist in a meaningful way between engine lifecycles.

    What I’m trying to achieve is simply a bounded set of log files, with no more log files than the configured maximum number of worker engines.

    For example, if the server is configured to allow up to 4 worker engines, I would like there to be only:

    - A.log
    - B.log
    - C.log
    - D.log

    So the idea is that worker/engine A owns "A.log", worker B owns "B.log", etc. If engine A goes down and a new engine is later spawned in its place, I would want that new engine to recognize that it should continue using "A.log".

    The reason I first considered PID-based filenames is that they uniquely identify a running process, but over time they produce more than 4 log files because respawned engines get new PIDs.

    I was wondering whether the port number might work as that stable worker identifier instead. I am trying to avoid multiple engines writing to the same file, so I don’t have to introduce file locking / semaphore logic and the complexity that comes with it
  • I think I was describing what you want, but perhaps not in a clear way. I do think we are back to the original problem. When an engine is spawned, it is launched with a new set of identifiers. Here is just one engine spawned from the OEngineServer:

    There isn't anything you can pull from this and assign it to "- A.log", "- B.log", etc.
  • Understood , thank you!
  • Sorry to butt in, but isn't there a method of spinning up 4 engines and for them to stay and not swap out. So thefore I assume there IDs will stay the same.
  • Hi Barry - If there is then I'm not familiar with it. However, if the OEngineServer needed to be restarted (as it sometimes does) then those newly spawned engines will have a different name.
  • Ah, yes of course.
Sign In or Register to comment.