# InstanceSpawn: Launch and maintain a group of server app instances

**URL:** <https://forum.xojo.com/t/instancespawn-launch-and-maintain-a-group-of-server-app-instances/79658>\
**Category:** Code Sharing\
**Created:** [March 20, 2024, 6:05pm UTC](https://forum.xojo.com/t/instancespawn-launch-and-maintain-a-group-of-server-app-instances/79658 "2024-03-20T18:05:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Georgios\_Poulopoulos](https://forum.xojo.com/user_avatar/forum.xojo.com/georgios_poulopoulos/32/16905_2.png) [@Georgios\_Poulopoulos](https://forum.xojo.com/u/Georgios_Poulopoulos)\
**Post date:** [March 20, 2024, 6:05pm UTC](https://forum.xojo.com/t/instancespawn-launch-and-maintain-a-group-of-server-app-instances/79658/1 "2024-03-20T18:05:28Z")

</div>

## [InstanceSpawn: An Instance Spawn Engine for stand-alone server apps](https://github.com/gregorplop/InstanceSpawn)

### A library to launch and maintain a group of command line argument-configured server instances

- Define command line arguments for each individual instance.
- Typically, assign each server instance a different listen port.
- Simultaneously launch the collection of instances as child processes.
- Set automatic restarts of instances that terminate (crash?)
- Get notified if an instance is down (run out of auto-restarts)
- Get notified if all instances terminated.
- Forcefully Terminate all instances.

### A harness application to demonstrate use of InstanceSpawn

- A GUI application, built and tested on Windows 10 and Linux Debian 12.
- Source code is the simple tutorial to integrate InstanceSpawn to your solution.
- Tested with [DummyWebApp](https://github.com/gregorplop/DummyWebApp)

### Ideas for solutions based on InstanceSpawn

- Service app that reads a configuration file and spawns server instances at system startup.
- Mechanism inside each server instance that monitors its own memory usage and auto-terminates instance when above a threshold, knowing that InstanceSpawn will launch a new instance.

 ![instancespawn](https://forum.xojo.com/uploads/default/original/3X/4/e/4ed913797dcc277f9db21ce9d84393fe8118cf7f.png)

---

<div class="post-metadata">

**Author:** ![MarkusR](https://forum.xojo.com/user_avatar/forum.xojo.com/markusr/32/685_2.png) [@MarkusR](https://forum.xojo.com/u/MarkusR)\
**Post date:** [March 20, 2024, 7:23pm UTC](https://forum.xojo.com/t/instancespawn-launch-and-maintain-a-group-of-server-app-instances/79658/2 "2024-03-20T19:23:50Z")

</div>

xojo web apps (exe) are usually registered as windows service.  
does this instancespawn behind scene?

---

<div class="post-metadata">

**Author:** ![Georgios\_Poulopoulos](https://forum.xojo.com/user_avatar/forum.xojo.com/georgios_poulopoulos/32/16905_2.png) [@Georgios\_Poulopoulos](https://forum.xojo.com/u/Georgios_Poulopoulos)\
**Post date:** [March 20, 2024, 7:49pm UTC](https://forum.xojo.com/t/instancespawn-launch-and-maintain-a-group-of-server-app-instances/79658/3 "2024-03-20T19:49:42Z")

</div>

As it stands, no, it’s a GUI app.  
The idea is to use the InstanceSpawn library (that the GUI app demonstrates how to use) to make a service app, then register it as a _single_ windows service, and have it spawn 10 server instances (you’d otherwise need to register one by one as a service).  
Then have your reverse proxy (nginx, caddy) load-balance across these 10 instances.

That’s the general outline.
