<@ULVA73B9P> Can I temporarily suspend starting sc...
# ask-marvin
o
@Marvin Can I temporarily suspend starting scheduled jobs on a server, so I can let running flows & tasks complete and have an idle server? I need this for version upgrades of the server.
m
To temporarily suspend starting new scheduled jobs in Prefect 3.x, you can use the
suspend_flow_run
and
resume_flow_run
functions. These functions allow you to suspend flow runs, which can be useful for pausing operations during server maintenance or upgrades. However, note that when a flow run is suspended, it exits completely, and the infrastructure running it is torn down. When resumed, the flow code will execute from the beginning of the flow, so task caching is recommended to avoid recomputing expensive operations. For your scenario, ensure all running flows and tasks complete before suspending new runs. You can manage this through the Prefect UI or programmatically using the mentioned functions. For more details, you can refer to the Prefect documentation on pause and resume. If you need to configure server settings, such as temporarily stopping the server API, you might consider adjusting server settings via environment variables or configuration files. More information can be found in the Prefect settings reference. Remember, in Prefect 3.x, agents are replaced by workers, so ensure your setup aligns with these changes.
o
@Marvin I would need the server to not start scheduled runs, too.
m
To prevent the server from starting scheduled runs, you can take a few approaches: 1. Pause Scheduled Runs: If you have access to the Prefect UI, you can manually pause scheduled runs. This will prevent new runs from being triggered. However, this requires manual intervention. 2. Disable the Scheduler: Temporarily disable the scheduler on your server. This can be done by stopping the scheduler process if it is running separately or by configuring the server not to start the scheduler. Unfortunately, Prefect's documentation doesn't provide a direct command for this, so you might need to handle it at the infrastructure level, depending on how your Prefect server is set up. 3. Modify Scheduled Flow Deployment: If you are using deployments, you can modify the schedule of your deployments to prevent new runs from starting. This can be done programmatically or via the UI. 4. Environment Configuration: You might explore environment variables or configuration files to adjust the server's behavior temporarily. These methods should help you achieve an idle server state for maintenance. If you're using specific infrastructure (like Kubernetes), ensure you're also following best practices for pausing or scaling down services. For more precise instructions, you may need to refer to your infrastructure's documentation or consult the Prefect community for specific configurations.