Skip to content

API - изменить логику установки (install)#53

Merged
andchir merged 3 commits intoandchir:mainfrom
konard:issue-52-62fc0a0e6a4e
Dec 25, 2025
Merged

API - изменить логику установки (install)#53
andchir merged 3 commits intoandchir:mainfrom
konard:issue-52-62fc0a0e6a4e

Conversation

@konard
Copy link
Copy Markdown
Contributor

@konard konard commented Dec 25, 2025

Summary

This PR implements the async installation logic as requested in #52.

Changes Made

  1. Background Thread Execution for /api/install

    • Installation now runs in a separate background thread
    • Returns immediately with a task_id for tracking
    • Same parameters generate the same task_id (using MD5 hash)
  2. New /api/status/<task_id> Endpoint

    • Returns installation status: processing, completed, or error
    • Returns current report content (result)
    • Auto-deletes task file when completed/error status is retrieved
    • Returns 404 on subsequent requests after cleanup
  3. Task File Management

    • Task files stored in api/tasks/ directory
    • File name is {task_id}.txt
    • Gradually populated with installation output
    • Cleaned up automatically when final status is retrieved

API Changes

POST /api/install - Changed response:

{
  "success": true,
  "task_id": "abc123...",
  "message": "Installation started"
}

GET /api/status/<task_id> - New endpoint:

{
  "success": true,
  "status": "processing|completed|error",
  "result": "Installation output..."
}

Implementation Details

  • Uses Python threading.Thread for background execution
  • MD5 hash of script_name:server_ip:server_root_password:additional for task_id
  • Task files contain STATUS: prefix line followed by output content
  • Streaming output written line by line during SSH execution
  • API version updated to 1.2.0

Test Plan

  • Run all unit tests (pytest examples/test_flask_api.py -v)
  • Verify task_id generation is consistent for same parameters
  • Verify status endpoint returns correct status values
  • Verify task file cleanup after completed/error status retrieval
  • Verify subsequent requests return 404 after cleanup

Fixes

Fixes #52

🤖 Generated with Claude Code

konard and others added 2 commits December 25, 2025 18:56
Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: andchir#52
- Add background thread execution for install endpoint
- Generate unique task_id using MD5 hash of input parameters
- Create api/status/<task_id> endpoint for status checking
- Return status (processing, completed, error) and result content
- Auto-delete task files when completed/error status is retrieved
- Add comprehensive tests for new functionality
- Update API version to 1.2.0

Fixes andchir#52

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@konard konard changed the title [WIP] API - изменить логику установки (install) API - изменить логику установки (install) Dec 25, 2025
@konard konard marked this pull request as ready for review December 25, 2025 18:04
@konard
Copy link
Copy Markdown
Contributor Author

konard commented Dec 25, 2025

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $3.298178 USD
  • Calculated by Anthropic: $2.346354 USD
  • Difference: $-0.951824 (-28.86%)
    📎 Log file uploaded as GitHub Gist (1024KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

@andchir andchir merged commit 8acf479 into andchir:main Dec 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

API - изменить логику установки (install)

2 participants