Skip to content

Latest commit

 

History

History
78 lines (50 loc) · 3.54 KB

File metadata and controls

78 lines (50 loc) · 3.54 KB

ProcessMaker/Models/ScriptExecutor.php - Executor Model with Docker Image Management

This file defines the ScriptExecutor model, which represents execution environments for different programming languages in ProcessMaker. It manages Docker image creation and configuration for script execution.

Class Overview

The ScriptExecutor class extends ProcessMakerModel and handles the management of execution environments for various scripting languages. It serves as a bridge between scripts and their execution environments.

Constants

  • MICROSERVICE_LANGUAGES: A list of supported languages and their executor names (PHP, JavaScript, Python, C#, Java, JavaScript SSR)

Traits Used

  • HasVersioning: Provides versioning capabilities for executors
  • Exportable: Makes executors exportable as part of process packages
  • HideSystemResources: Hides system executors from regular queries

Core Properties

  • protected $fillable: Specifies mass-assignable attributes (title, description, etc.)
  • protected $casts: Defines attribute casting (type as ScriptExecutorType enum)

Executor Types

The model uses an enum for different executor types:

  • System: Built-in executors provided by ProcessMaker
  • Custom: User-defined executors
  • Duplicate: Copies of existing executors

Active Scope

The scopeActive() method filters out deprecated languages (Lua and R) to maintain backward compatibility while indicating these will be removed in future versions.

Installation and Initialization

  • install(): Installs or updates an executor based on parameters, also updating existing scripts that use the same language
  • initialExecutor(): Returns the first executor for a given language ordered by creation date

Docker Configuration Methods

Several methods manage Docker-specific configurations:

  • initDockerfile(): Combines the base Dockerfile with initialization instructions for a language
  • finalInstructions(): Returns final Dockerfile instructions for a language
  • packagePath(): Returns the path to the language package
  • config(): Returns configuration for a specific language from the script-runners config

Validation System

The rules() method provides validation for executor creation/update, ensuring only supported languages are used and excluding deprecated ones for new executors.

Executor Listing

The list() method returns available executors with options to filter by language and for edit mode (which special cases PHP and php-nayra languages).

Docker Image Management

Key methods for Docker image management:

  • dockerImageName(): Generates the Docker image name following the pattern 'processmaker4/executor-{instance}-{language}-{id}:{tag}'
  • imageTag(): Creates version tags for Docker images
  • dockerImageExists(): Checks if the executor's Docker image exists locally
  • listOfExecutorImages(): Queries Docker to list all ProcessMaker executor images

Relationships

  • versions(): Links to executor version history
  • scripts(): One-to-many relationship with scripts that use this executor
  • getScriptsCountAttribute(): Computed property that returns the count of associated scripts

Purpose

This model serves as the central management point for execution environments, handling:

  • Configuration for different programming languages
  • Docker image generation and naming
  • Relationship management between executors and scripts
  • Lifecycle management of execution environments

The ScriptExecutor model is essential for ProcessMaker's ability to securely execute scripts in multiple languages through isolated Docker containers.