Skip to content

App launcher: allows to pass custom PID back to AYON#255

Merged
antirotor merged 8 commits intodevelopfrom
enhancement/pass-custom-pid
Sep 23, 2025
Merged

App launcher: allows to pass custom PID back to AYON#255
antirotor merged 8 commits intodevelopfrom
enhancement/pass-custom-pid

Conversation

@antirotor
Copy link
Copy Markdown
Member

@antirotor antirotor commented Sep 16, 2025

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_file entry. If set, app_launcher will set AYON_PID_FILE environment 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:

  1. Set the executable to be a script like:
#!/bin/bash

# Launch the actual application in background
/path/to/actual/application "$@" &

# Get the PID of the actual application
APP_PID=$!

# Write the PID to the AYON PID file if available
if [ -n "$AYON_PID_FILE" ]; then
    echo "$APP_PID" > "$AYON_PID_FILE"
fi
  1. The Process Manager should show the correct PID

@antirotor antirotor self-assigned this Sep 16, 2025
@antirotor antirotor added the type: enhancement Improvement of existing functionality or minor addition label Sep 16, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_file parameter in JSON input to specify where scripts can write PIDs
  • Enhanced both Python and C++ launchers to set AYON_PID_FILE environment 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.

antirotor and others added 2 commits September 16, 2025 22:50
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@iLLiCiTiT
Copy link
Copy Markdown
Member

There are conflicts in the PR.

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:
Copy link
Copy Markdown
Member

@iLLiCiTiT iLLiCiTiT Sep 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

@iLLiCiTiT iLLiCiTiT Sep 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@antirotor antirotor merged commit cacc53b into develop Sep 23, 2025
1 check passed
@antirotor antirotor deleted the enhancement/pass-custom-pid branch September 23, 2025 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: enhancement Improvement of existing functionality or minor addition

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants