tourze / server-application-bundle
服务端应用管理系统,提供应用模板、实例管理、生命周期控制等功能
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
pkg:composer/tourze/server-application-bundle
Requires
- ext-json: *
- doctrine/collections: ^2.3
- doctrine/data-fixtures: ^2.0
- doctrine/dbal: ^4.0
- doctrine/doctrine-bundle: ^2.13
- doctrine/doctrine-fixtures-bundle: ^4.0
- doctrine/orm: ^3.0
- doctrine/persistence: ^4.1
- easycorp/easyadmin-bundle: ^4
- knplabs/knp-menu: ^3.7
- symfony/config: ^7.3
- symfony/console: ^7.3
- symfony/dependency-injection: ^7.3
- symfony/doctrine-bridge: ^7.3
- symfony/form: ^7.3
- symfony/framework-bundle: ^7.3
- symfony/http-foundation: ^7.3
- symfony/http-kernel: ^7.3
- symfony/messenger: ^7.3
- symfony/property-access: ^7.3
- symfony/routing: ^7.3
- symfony/security-core: ^7.3
- symfony/serializer: ^7.3
- symfony/yaml: ^7.3
- tourze/arrayable: 1.*
- tourze/bundle-dependency: 1.*
- tourze/doctrine-indexed-bundle: 1.0.*
- tourze/doctrine-ip-bundle: 1.1.*
- tourze/doctrine-timestamp-bundle: 1.1.*
- tourze/doctrine-track-bundle: 1.1.*
- tourze/doctrine-user-bundle: 1.0.*
- tourze/easy-admin-menu-bundle: 1.0.*
- tourze/enum-extra: 1.0.*
- tourze/server-node-bundle: 1.0.*
- tourze/symfony-dependency-service-loader: 1.0.*
Requires (Dev)
This package is auto-updated.
Last update: 2025-11-18 08:36:56 UTC
README
Server application management bundle for managing application lifecycle, deployment, and monitoring.
Table of Contents
Features
- Application Templates: Define reusable templates for server applications
- Instance Management: Create and manage application instances from templates
- Lifecycle Management: Track application lifecycle events (install, health check, uninstall)
- Port Configuration: Manage application port mappings and configurations
- Execution Steps: Define and track custom execution steps for deployments
- Logging: Comprehensive logging of all lifecycle events and operations
- Multi-node Support: Deploy applications across multiple server nodes
Installation
composer require tourze/server-application-bundle
Configuration
No additional configuration is required. The bundle auto-configures itself using Symfony's autowiring.
Usage
Core Entities
AppTemplate
Defines reusable application templates with configuration, health checks, and execution steps.
use ServerApplicationBundle\Entity\AppTemplate; $template = new AppTemplate(); $template->setName('Web Server'); $template->setDescription('Nginx web server template'); $template->setImage('nginx:latest');
AppInstance
Represents an actual instance of an application deployed from a template.
use ServerApplicationBundle\Entity\AppInstance; $instance = new AppInstance(); $instance->setTemplate($template); $instance->setName('production-web-server'); $instance->setNode($serverNode);
AppLifecycleLog
Tracks all lifecycle events and operations performed on application instances.
Services
- AppTemplateService: Manage application templates
- AppInstanceService: Handle application instance operations
- AppLifecycleLogService: Log and query lifecycle events
- AppPortConfigurationService: Manage port configurations
- AppPortMappingService: Handle port mappings between host and container
- AppExecutionStepService: Manage custom execution steps
Admin Interface
The bundle integrates with EasyAdmin to provide a comprehensive admin interface:
// Access the admin interface at /admin // Manage templates, instances, logs, and configurations
Command Line Interface
# List all application templates bin/console app:template:list # Deploy an application instance bin/console app:instance:deploy <template-id> <node-id> # Check application health bin/console app:instance:health-check <instance-id>
Advanced Usage
Custom Execution Steps
Create custom execution steps for complex deployment scenarios:
use ServerApplicationBundle\Entity\AppExecutionStep; use ServerApplicationBundle\Enum\ExecutionStepType; $step = new AppExecutionStep(); $step->setTemplate($template); $step->setSequence(1); $step->setName('Install Dependencies'); $step->setType(ExecutionStepType::COMMAND); $step->setContent('apt-get update && apt-get install -y nginx'); $step->setWorkingDirectory('/tmp'); $step->setUseSudo(true); $step->setTimeout(300); $step->setRetryCount(3);
Health Check Configuration
Configure health checks for your applications:
use ServerApplicationBundle\Entity\AppPortConfiguration; use ServerApplicationBundle\Enum\HealthCheckType; use ServerApplicationBundle\Enum\ProtocolType; $portConfig = new AppPortConfiguration(); $portConfig->setTemplate($template); $portConfig->setPort(80); $portConfig->setProtocol(ProtocolType::TCP); $portConfig->setHealthCheckType(HealthCheckType::TCP_CONNECT); $portConfig->setHealthCheckInterval(60); $portConfig->setHealthCheckTimeout(5); $portConfig->setHealthCheckRetries(3);
Environment Variables
Manage environment variables for your applications:
$template->setEnvironmentVariables([ 'NODE_ENV' => 'production', 'PORT' => '8080', 'DATABASE_URL' => 'mysql://user:pass@localhost/db' ]); $instance->setEnvironmentVariables([ 'NODE_ENV' => 'production', 'PORT' => '8080' ]);
Lifecycle Event Handling
Track and respond to lifecycle events:
use ServerApplicationBundle\Entity\AppLifecycleLog; use ServerApplicationBundle\Enum\LifecycleActionType; use ServerApplicationBundle\Enum\LogStatus; $log = new AppLifecycleLog(); $log->setInstance($instance); $log->setAction(LifecycleActionType::INSTALL); $log->setStatus(LogStatus::SUCCESS); $log->setMessage('Application installed successfully'); $log->setExecutionTime(45.2);
Architecture
The bundle follows a service-oriented architecture with:
- Entities: Domain models for templates, instances, logs, etc.
- Repositories: Data access layer with custom query methods
- Services: Business logic layer for operations
- Controllers: Admin interface controllers
- Enums: Type-safe enumerations for statuses and types
Dependencies
- Symfony 6.4+
- PHP 8.1+
- Doctrine ORM 3.0+
- EasyAdmin Bundle 4+
- tourze/server-node-bundle
- tourze/doctrine-timestamp-bundle
- tourze/doctrine-ip-bundle
- tourze/doctrine-track-bundle
- tourze/doctrine-user-bundle
Testing
Run the test suite:
./vendor/bin/phpunit packages/server-application-bundle/tests
License
MIT License. See LICENSE file for details.