mirror of
https://github.com/moghtech/komodo.git
synced 2026-03-09 07:13:36 -05:00
[PR #664] [MERGED] Implement ability to run actions at startup #758
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/moghtech/komodo/pull/664
Author: @bpbradley
Created: 7/14/2025
Status: ✅ Merged
Merged: 7/28/2025
Merged by: @mbecker20
Base:
1.18.5← Head:run_on_startup📝 Commits (2)
fb8b325Implement ability to run actions at startup482322crun post-startup actions after server is listening📊 Changes
6 files changed (+94 additions, -2 deletions)
View changed files
📝
bin/core/src/main.rs(+18 -1)📝
bin/core/src/startup.rs(+51 -1)📝
client/core/rs/src/entities/action.rs(+11 -0)📝
client/core/ts/src/types.ts(+2 -0)📝
frontend/public/client/types.d.ts(+2 -0)📝
frontend/src/components/resources/action/config.tsx(+10 -0)📄 Description
This feature adds a "Run On Startup" feature for Actions. When enabled, the action will be executed shortly after Komodo Core finishes loading.
Now first, I am experienced in C, not Rust, so forgive me if I did anything stupid. I mostly just borrowed from how actions were run in
schedule.rsfor borrowing the syntax / patterns to do what I wanted to do.Originally, I added the startup actions in
startup.rsat the end of theon_startupfunction (like this)And this "worked", but the actions always failed with
My reasoning was that this needed to occur after the server becomes available here
However, I don't really know how to get it to run after this in the way I was hoping.So I sort of hacked it by just spawning the process to run the actions in the background with a delay, before the server starts.
This now works, and actions execute successfully a few seconds after server starts.
But it definitely feels like I could probably do this in a way that doesn't introduce a possible race condition. That said, I felt 5 seconds was pretty generous.
Edit: I changed the implementation. Did some reading and found
axum_server::Handle::listening()which I was able to leverage with minimal changes to make sure the action only runs after the handle is listening.With that, it does work for me.
And the action runs successfully after server startup
And actions which do not have this enabled do not run at startup, as expected. So functionally I think it works.
Very welcome to changing how I do this, like I said I am not super familiar with this toolchain.
Edit:
I was also thinking (assuming this feature is desired, of course) that it may be necessary to implement some env/config option that disables this feature globally. Reason being that I'm not sure if there may be some way to bootloop your system by a broken action that causes core to restart. I'm not sure if that is possible, but would be quite annoying if it were.
I suppose the 5 second delay could save them here.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.