From 795fcd7ff178c4561bfe9a013b955dfd79532c9f Mon Sep 17 00:00:00 2001 From: Ben Allfree Date: Sat, 29 Jun 2024 14:28:58 -0700 Subject: [PATCH] feat(pockethost): kill instance action --- .changeset/shaggy-foxes-protect.md | 5 +++++ packages/pockethost/plugin-guide.md | 6 ++++++ packages/pockethost/src/common/plugin/action.ts | 7 +++++++ 3 files changed, 18 insertions(+) create mode 100644 .changeset/shaggy-foxes-protect.md diff --git a/.changeset/shaggy-foxes-protect.md b/.changeset/shaggy-foxes-protect.md new file mode 100644 index 00000000..f993d939 --- /dev/null +++ b/.changeset/shaggy-foxes-protect.md @@ -0,0 +1,5 @@ +--- +'pockethost': minor +--- + +New action: KillInstance diff --git a/packages/pockethost/plugin-guide.md b/packages/pockethost/plugin-guide.md index e60d6018..9a8c0849 100644 --- a/packages/pockethost/plugin-guide.md +++ b/packages/pockethost/plugin-guide.md @@ -137,6 +137,12 @@ onServeAction(async ({ only }) => { Fired after all plugins have been loaded. This is a good time to perform initialization that may depend upon other plugins. +#### KillInstance (since 1.6.0) + +```ts +await doKillInstanceAction({ instance }) +``` + ### Core Filters #### ServerSlugs (since 1.4.0) diff --git a/packages/pockethost/src/common/plugin/action.ts b/packages/pockethost/src/common/plugin/action.ts index 0f67d1b6..49a3af48 100644 --- a/packages/pockethost/src/common/plugin/action.ts +++ b/packages/pockethost/src/common/plugin/action.ts @@ -21,6 +21,8 @@ enum CoreActions { BeforeInstanceStarted = 'core_before_instance_started', AfterInstanceStarted = 'core_after_instance_started', + KillInstance = 'core_kill_instance', + BeforeInstanceStopped = 'core_before_instance_stopped', AfterInstanceStopped = 'core_after_instance_stopped', @@ -140,6 +142,11 @@ export const [doAfterInstanceStartedAction, onAfterInstanceStartedAction] = CoreActions.AfterInstanceStarted, ) +export const [doKillInstanceAction, onKillInstanceAction] = + createCustomActionWithContext<{ instance: InstanceFields }>( + CoreActions.KillInstance, + ) + export const [doBeforeInstanceStoppedAction, onBeforeInstanceStoppedAction] = createCustomActionWithContext<{ instance: InstanceFields; url: string }>( CoreActions.BeforeInstanceStopped,