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.
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.
MICROSERVICE_LANGUAGES: A list of supported languages and their executor names (PHP, JavaScript, Python, C#, Java, JavaScript SSR)
HasVersioning: Provides versioning capabilities for executorsExportable: Makes executors exportable as part of process packagesHideSystemResources: Hides system executors from regular queries
protected $fillable: Specifies mass-assignable attributes (title, description, etc.)protected $casts: Defines attribute casting (type as ScriptExecutorType enum)
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
The scopeActive() method filters out deprecated languages (Lua and R) to maintain backward compatibility while indicating these will be removed in future versions.
install(): Installs or updates an executor based on parameters, also updating existing scripts that use the same languageinitialExecutor(): Returns the first executor for a given language ordered by creation date
Several methods manage Docker-specific configurations:
initDockerfile(): Combines the base Dockerfile with initialization instructions for a languagefinalInstructions(): Returns final Dockerfile instructions for a languagepackagePath(): Returns the path to the language packageconfig(): Returns configuration for a specific language from the script-runners config
The rules() method provides validation for executor creation/update, ensuring only supported languages are used and excluding deprecated ones for new executors.
The list() method returns available executors with options to filter by language and for edit mode (which special cases PHP and php-nayra languages).
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 imagesdockerImageExists(): Checks if the executor's Docker image exists locallylistOfExecutorImages(): Queries Docker to list all ProcessMaker executor images
versions(): Links to executor version historyscripts(): One-to-many relationship with scripts that use this executorgetScriptsCountAttribute(): Computed property that returns the count of associated scripts
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.