App launcher: allows to pass custom PID back to AYON#255
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR enables AYON's app launcher to receive and track custom PIDs from wrapper shell scripts, supporting proper process monitoring in the Process Manager. The enhancement allows shell scripts to write the actual application PID to a file, which the launcher then reads and uses for process tracking.
- Added support for
pid_fileparameter in JSON input to specify where scripts can write PIDs - Enhanced both Python and C++ launchers to set
AYON_PID_FILEenvironment variable and read back custom PIDs - Added configurable stdout/stderr redirection support in both implementations
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| app_launcher.py | Added PID file handling, custom PID reading, and stdout/stderr redirection support |
| app_launcher.cpp | Implemented equivalent functionality in C++ with PID file support and output redirection |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
There are conflicts in the PR. |
Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>
app_launcher.py
Outdated
|
|
||
| # Add AYON_PID_FILE environment variable if pid_file is specified | ||
| pid_file_path = data.get("pid_file") | ||
| if pid_file_path and "AYON_PID_FILE" not in env: |
There was a problem hiding this comment.
Comment disappeared with resolving. This really should set the env if the file is explicitly set in the source json. And to be honest I think it should unset it if it's not there so we do avoid inheriting the env values from parent process by accident.
There was a problem hiding this comment.
Or do not expect it in the json and just set in in env. Which is maybe better because the launcher is not really the source of the logic... -> we don't have to store the PID here.
Changelog Description
When launching application using wrapper shell scripts, give possibility to pass resulting PID back. This allows to track the main process in Process Manager implemented in ynput/ayon-applications#94
Additional info
JSON passed to app_launcher has
pid_fileentry. If set, app_launcher will setAYON_PID_FILEenvironment variable just before the process is launched. If it is the shell script (but frankly, whatever else) it can take this variable, write the PID there. This is then read back and used to monitor the process.Warning
This already has changes from #254
Testing notes: