-
Notifications
You must be signed in to change notification settings - Fork 15
Auto-track and globally shut down all Forge actors and services #357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This method is used by `Service` to teardown a replica. | ||
""" | ||
if not quiet: | ||
logger.info(f"Shutting down actor {getattr(actor, 'name', cls.__name__)}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding this quiet check because otherwise when we shutdown a service, it would call actor.shutdown and print the log twice.
|
||
async def track_allocation(self, alloc: Any): | ||
"""Tracks an allocation for cleanup.""" | ||
self._allocations.append(alloc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm, I think an even simpler approach is to just track the proc meshes right? We can just do await proc_mesh.stop()
and I think everything inside of it should shut down neatly. Let me know if that doesn't work though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would work for actor since shutting down actor is essentially stopping the proc_mesh
.
But for service, it involves some other operations such as stopping the replicas and healthy loop.
Context: #360
This PR adds automatic allocation tracking for all
ForgeActor
andServiceInterface
instances via the globalProvisioner
.Actors and services are now automatically registered with the provisioner when spawned through
.as_actor()
or.as_service()
, enabling unified lifecycle management and eliminating the need for manual shutdown calls.Changes
ForgeActor.as_service()
Registers the top-level
ServiceInterface
proxy (instead of rawActorMesh
) after initialization.ForgeActor.as_actor()
Registers the spawned
ForgeActor
proxy after successful setup.Provisioner.shutdown_all_allocations()
Handles both
ForgeActor
andServiceInterface
cleanly; internalActorMesh
handles are no longer registered.Result
All actors and services are now automatically tracked and can be shut down gracefully with a single call.
Before
After
Test:
The log after ctrl+C (cleaned version):
TODO:
Merge
in the centralized shutdown.
Will do it after the Monarch error with the logger (#360 (3)) is fixed. Fixing it is out of scope of this PR.