Nodes/Santodan Random LoRA Node/SaveWorkflowAndShutdown
ComfyUI Node

SaveWorkflowAndShutdown

Let the machine power down when the queue empties

By Santodan·Created about a year ago·Updated 2 months ago· 28
SaveWorkflowAndShutdown
  • trigger
  • passthrough
  • status
enabledfalse
delay_seconds60
save_workflowtrue
save_mode
filename_prefixworkflow_autosave.json

If you've ever queued a long batch and gone to bed hoping the render finishes without the machine idling all night, this node is aimed squarely at you. SaveWorkflowAndShutdown sits at the end of your graph, watches the queue, and when the last job completes it saves a copy of the workflow and powers the PC off. Set it, queue, walk away.

The name is the spec. It's a "I want this to be done and the machine off when I come back" convenience node, and nothing more - which is fine, because that's a genuinely annoying problem to solve manually with a scheduler.

How it works

Wire any output into trigger (it's an any-type input, so anything can feed it and it passes straight through to passthrough). On each run the node asks the prompt queue how many jobs remain. When this is the last job, a frontend hook calls the pack's /save_and_shutdown/trigger API route, which:

  1. Confirms the queue is actually empty (it re-checks server-side - if other jobs remain, it aborts and waits).
  2. Saves the workflow - either overwriting the currently loaded file (Overwrite Existing File mode) or writing a new timestamped file into ComfyUI's output folder (Save as New Timestamped File mode) with your filename_prefix.
  3. Sleeps delay_seconds (default 60, min 10), then runs the OS shutdown command: shutdown /s /t 1 on Windows, sudo shutdown -h now on Linux/macOS.

The status output tells you which state you're in: disabled, waiting with N jobs queued, or triggering shutdown.

Settings

  • trigger - any connection; purely to place the node in the graph.
  • enabled - must be True or nothing happens (the node defaults to disabled, which is the safe default).
  • delay_seconds - the shutdown countdown, so you can cancel.
  • save_workflow, save_mode, filename_prefix - whether and how the workflow is saved first.
  • Outputs: passthrough (your trigger value, unchanged) and status (a readable string).

The honest warnings

  • sudo shutdown is the fragile part. On Linux/macOS the command needs root without a password prompt, or it silently fails at the end - you'll see the error in the ComfyUI console and the machine stays on. Set up passwordless sudo for the shutdown command if you actually want this to work.
  • Your only cancel is the delay window. The README is blunt: "if you want to interrupt, cancel comfyui's process." During the countdown, kill the ComfyUI process and the shutdown aborts. After that, the OS takes over - your saved workflow is on disk, but unsaved anything-else is gone.
  • It saves the workflow JSON, not your generations. Images are saved by your SaveImage nodes as usual; this node only guarantees the workflow graph is on disk so you can rebuild the run. Set save_workflow off and you get shutdown with no autosave.
  • Queue-counting edge cases. It checks "jobs remaining" including the current one, so a workflow that queues more items mid-run (an "efficient loader" or a loop that re-queues) will see this as not-the-last-job and wait. That's correct, just don't expect it to force a shutdown past a re-queueing graph.

Install

ComfyUI Manager (search "Santodan"), or:

cd ComfyUI/custom_nodes
git clone https://github.com/Santodan/santodan-custom-nodes-comfyui

Restart. No dependencies, no downloads. Test it once with enabled on and a tiny delay_seconds while you're in the room - shutdown nodes deserve a dry run.

Categoryutils

Inputs (6)

NameTypeDefaultDescription
trigger*
enabledBOOLEANfalse
delay_secondsINT6010–600
save_workflowBOOLEANtrue
save_modeCOMBO2 options: Overwrite Existing File, Save as New Timestamped File
filename_prefixSTRINGworkflow_autosave.json

Outputs (2)

NameTypeDescription
passthrough*
statusSTRING