Skip to content

Commit 371be1e

Browse files
committed
add support for unique working dir
- allows multiple script runners to be run concurrently - add some additional safe guard checks - improve readme - move JFR logs to logs directory
1 parent e6dfe6b commit 371be1e

8 files changed

Lines changed: 360 additions & 29 deletions

File tree

.github/workflows/main.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ jobs:
3131
run: ant -DluceeVersionQuery="6/all/jar" -Dexecute="/debug.cfm"
3232

3333
- name: Run Lucee 6 Stable
34-
run: ant -DluceeVersion="6.0.3.1" -Dexecute="/debug.cfm" -Dtruth="cfml rocks" -Dauthor="Zac Spitzer"
34+
run: ant -DluceeVersion="6.2.2.91" -Dexecute="/debug.cfm" -Dtruth="cfml rocks" -Dauthor="Zac Spitzer"
3535

3636
- name: Run Lucee 5 (using Lucee light, no extensions)
3737
run: ant -DluceeVersion="light-5.4.2.17" -Dexecute="/debug.cfm"
3838

3939
- name: Run Lucee 6 (using Lucee zero, no extensions, no admin, no docs)
40-
run: ant -DluceeVersion="zero-6.0.3.1" -Dexecute="/debug.cfm"
40+
run: ant -DluceeVersion="zero-6.2.2.91" -Dexecute="/debug.cfm"
4141

4242
- name: Run Latest Lucee 5 RC Light
4343
run: ant -DluceeVersionQuery="5/rc/light" -Dexecute="/debug.cfm"
@@ -48,3 +48,9 @@ jobs:
4848
- name: Run Latest Stable Lucee 5, compile webroot (invalid code)
4949
continue-on-error: true
5050
run: ant -DluceeVersionQuery="5/stable/jar" -Dexecute="/index.cfm" -Dcompile="true" -Dwebroot="${{ github.workspace }}/sampleBad/"
51+
52+
- name: Test concurrent execution with unique working directories
53+
run: |
54+
ant -DuniqueWorkingDir="true" -Dexecute="/debug.cfm" &
55+
ant -DuniqueWorkingDir="true" -Dexecute="/debug.cfm" &
56+
wait

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
lucee-download-cache
22
temp
33
bin
4+
logs

CHANGELOG.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Changelog
2+
3+
All notable changes to the Lucee Script Runner project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
### Added
11+
- **Unique Working Directories**: Added `uniqueWorkingDir` parameter with three modes:
12+
- `false` (default): Uses standard temp/lucee directory
13+
- `true`: Auto-generates unique directory with timestamp and random ID
14+
- Custom path: Uses specified directory path
15+
- **Concurrent Execution Support**: Multiple script-runner instances can now run simultaneously without conflicts
16+
- **Race Condition Detection**: Automatic detection and prevention of directory conflicts
17+
- **Improved JFR Logging**:
18+
- JFR files now output to organized `logs/` directory
19+
- Descriptive filenames: `timestamp-lucee-version-webroot-script-javaversion.jfr`
20+
- Added `logs/` to `.gitignore`
21+
- **Enhanced Error Messages**:
22+
- Git Bash path conversion detection with specific solutions
23+
- Execute script validation with exact file path shown
24+
- Windows trailing backslash validation
25+
- **Cross-Platform Path Handling**: Robust path concatenation logic for Windows and Unix systems
26+
27+
### Changed
28+
- **Updated Lucee Version**: Standardized all references to version 6.2.2.91 across codebase
29+
- **JFR Filename Format**: Changed from `lucee-version.jar-javaversion.jfr` to descriptive format with timestamp and context
30+
- **Documentation**: Updated README.md with comprehensive working directory behavior explanations
31+
32+
### Fixed
33+
- **File Path Validation Bug**: Fixed concatenation logic for execute script validation
34+
- **Git Bash Path Conversion Issues**: Added detection and helpful error messages for MSYS path conversion problems
35+
- **Build Script Path Resolution**: Fixed relative path issues when using unique working directories
36+
37+
### Technical Details
38+
39+
#### New Ant Properties
40+
- `uniqueWorkingDir`: Controls working directory behavior
41+
- `webroot.name`: Extracted basename of webroot for JFR filenames
42+
- `execute.clean`: Cleaned execute path (removes leading slashes) for JFR filenames
43+
- `execute.fullpath`: Properly concatenated full path for file validation
44+
45+
#### Build Process Improvements
46+
- Added `set-unique-working-dir` target with timestamp generation and race condition checks
47+
- Enhanced `run-cfml` target with improved validation and path handling
48+
- Updated GitHub Actions workflow with concurrent execution tests
49+
50+
#### Error Handling
51+
- Early validation of execute script existence under webroot
52+
- Specific error messages for common Git Bash issues
53+
- Clear guidance on workarounds and solutions
54+
55+
### Migration Notes
56+
- Existing usage remains unchanged (backward compatible)
57+
- New JFR files will appear in `logs/` directory instead of project root
58+
- Git users should add `logs/` to their `.gitignore` if not already present

README.md

Lines changed: 148 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,44 @@ Quickly run Lucee CFML applications headless (without a HTTP server) via the com
66

77
Please report any issues, etc in the [Lucee Issue Tracker](https://luceeserver.atlassian.net/issues/?jql=labels%20%3D%20%22script-runner%22)
88

9+
## Project Structure
10+
11+
- `build.xml` - Main build file (always use this)
12+
- `build-run-cfml.xml` - Internal file (do not run directly)
13+
- `action.yml` - GitHub Action configuration
14+
- `sample/` - Example CFML files for testing
15+
916
## Command line Usage
1017

18+
### Running from Different Directories
19+
20+
The script-runner can be used from any directory by specifying the build file location:
21+
22+
```bash
23+
# From the script-runner directory (simple)
24+
ant -Dwebroot="/path/to/your/project" -Dexecute="/yourscript.cfm"
25+
26+
# From your project directory (recommended for external projects)
27+
ant -buildfile="/path/to/script-runner/build.xml" -Dwebroot="." -Dexecute="/yourscript.cfm"
28+
29+
# From any directory with absolute paths
30+
ant -buildfile="C:\tools\script-runner\build.xml" -Dwebroot="C:\work\myproject" -Dexecute="/test.cfm"
31+
```
32+
33+
**Key Points:**
34+
- `-buildfile` specifies where script-runner is installed
35+
- `-Dwebroot` is the directory containing your CFML code (can be relative to current directory)
36+
- `-Dexecute` is the CFML script to run (relative to webroot)
37+
38+
### Basic Usage
39+
1140
Default `ant` will run the `sample/index.cfm` file
1241

1342
![image](https://user-images.githubusercontent.com/426404/122402355-b0dbf980-cf7d-11eb-8837-37dec47d0713.png)
1443

1544
You can specify:
1645

17-
- Lucee version `-DluceeVersion=` default `6.0.3.1`, (ie. 6.3.0.1, light-6.3.0.1, zero-6.3.0.1 )
46+
- Lucee version `-DluceeVersion=` default `6.2.2.91`, (ie. 6.2.2.91, light-6.2.2.91, zero-6.2.2.91 )
1847
- Lucee version by query `-DluceeVersionQuery="5.4/stable/light` ( optional overrides luceeVersion, (version)/(stable/rc/snapshot)/(jar,light/zero) )
1948
- Webroot `-Dwebroot=` (default `tests/`) on Windows, avoid a trailing \ as that is treated as an escape character causes script runner to fail
2049
- CFML Script to run, `-Dexecute=` (default `/index.cfm`)
@@ -26,16 +55,129 @@ You can specify:
2655
- use a java debugger `-Ddebugger="true"` opens a java debugging port 5000, with suspend=y
2756
- preCleanup `-DpreCleanup="true"` purges the Lucee working dir before starting
2857
- postCleanup `-DpostCleanup="true"` purges the Lucee working dir after finishing
58+
- uniqueWorkingDir `-DuniqueWorkingDir=` supports three modes:
59+
- `"false"` (default): Uses standard `temp/lucee` directory
60+
- `"true"`: Auto-generates unique directory `temp-unique/lucee-{VERSION}-{TIMESTAMP}-{RANDOM}`
61+
- `"/custom/path"`: Uses specified custom directory path
62+
63+
`ant -DluceeVersion="6.2.2.91" -Dwebroot="C:\work\lucee-docs" -Dexecute="import.cfm" -Dlucee.extensions=""`
64+
65+
`ant -DluceeVersion="6.2.2.91" -DextensionDir="C:\work\lucee-extensions\extension-hibernate\dist"`
66+
67+
### Quick Reference Examples
68+
69+
```bash
70+
# Testing Lucee Spreadsheet from its directory
71+
cd D:\work\lucee-spreadsheet
72+
ant -buildfile=D:\work\script-runner\build.xml -Dwebroot=. -Dexecute=/test/index.cfm
73+
74+
# Testing with specific Lucee version
75+
ant -buildfile=D:\work\script-runner\build.xml -DluceeVersionQuery=6.2/stable/jar -Dwebroot=D:\work\lucee-spreadsheet -Dexecute=/test/index.cfm
76+
77+
# With unique working directory for concurrent runs
78+
ant -buildfile=D:\work\script-runner\build.xml -DuniqueWorkingDir=true -Dwebroot=D:\work\lucee-spreadsheet -Dexecute=/test/index.cfm
79+
```
80+
81+
### Working Directory Behavior
82+
83+
**Default Mode** (`uniqueWorkingDir=false` or not specified):
84+
- Uses a consistent local `temp/lucee` directory relative to script-runner location
85+
- Same directory is reused across runs (cleaned with `preCleanup`/`postCleanup`)
86+
- **Ideal for CI/CD**: Predictable location, faster subsequent runs due to caching
87+
- **Single instance only**: Cannot run multiple concurrent instances
88+
89+
**Auto-Unique Mode** (`uniqueWorkingDir=true`):
90+
- Creates unique directories: `temp-unique/lucee-{VERSION}-{TIMESTAMP}-{RANDOM}`
91+
- Each run gets its own isolated working directory
92+
- **Enables concurrent execution**: Multiple instances can run simultaneously
93+
- **Useful for**: Parallel testing, concurrent builds, isolation requirements
94+
95+
**Custom Path Mode** (`uniqueWorkingDir=/custom/path`):
96+
- Uses your specified directory as the working directory
97+
- Full control over location (e.g., RAM disk, specific drive, shared folder)
98+
- **Race protection**: Still checks for existing directory to prevent conflicts
99+
- **Useful for**: Custom environments, performance optimization, specific storage requirements
100+
101+
```bash
102+
# Examples of the three modes:
103+
ant -DuniqueWorkingDir=false # Uses: temp/lucee
104+
ant -DuniqueWorkingDir=true # Uses: temp-unique/lucee-6.2.2.91-20250908-090047-669
105+
ant -DuniqueWorkingDir=C:/fast/work # Uses: C:/fast/work
106+
```
29107

30-
`ant -DluceeVersion="6.0.0.95-SNAPSHOT" -Dwebroot="C:\work\lucee-docs" -Dexecute="import.cfm" -Dlucee.extensions=""`
108+
### Concurrent Execution
109+
110+
Multiple script-runner instances can be run simultaneously using unique working directories:
111+
112+
```bash
113+
# Run multiple instances concurrently
114+
ant -DuniqueWorkingDir="true" -Dexecute="/test1.cfm" &
115+
ant -DuniqueWorkingDir="true" -Dexecute="/test2.cfm" &
116+
ant -DuniqueWorkingDir="true" -Dexecute="/test3.cfm" &
117+
wait
118+
```
119+
120+
Each instance will use a unique working directory named `temp-unique/lucee-{VERSION}-{TIMESTAMP}-{RANDOM}` to prevent conflicts.
121+
122+
## Troubleshooting
123+
124+
### Common Issues on Windows
125+
126+
**Problem**: Build fails with path-related errors
127+
**Solution**: Avoid trailing backslashes in webroot paths:
128+
```bash
129+
# ❌ Wrong - trailing backslash causes escape issues
130+
ant -Dwebroot="C:\work\myproject\"
131+
132+
# ✅ Correct - no trailing backslash
133+
ant -Dwebroot="C:\work\myproject"
134+
ant -Dwebroot="C:/work/myproject/" # Forward slashes work too
135+
```
136+
137+
**Problem**: "Could not locate build file" from other directories
138+
**Solution**: Use absolute path to build.xml:
139+
```bash
140+
# ❌ Wrong - looking for build.xml in current directory
141+
ant -Dwebroot="." -Dexecute="/test.cfm"
142+
143+
# ✅ Correct - specify script-runner location
144+
ant -buildfile="C:\tools\script-runner\build.xml" -Dwebroot="." -Dexecute="/test.cfm"
145+
```
146+
147+
**Problem**: "File not found" for CFML scripts
148+
**Solution**: Check webroot and execute paths:
149+
```bash
150+
# Verify your paths - execute is relative to webroot
151+
ant -buildfile="/path/to/script-runner/build.xml" -Dwebroot="/your/project" -Dexecute="/debug.cfm"
152+
```
153+
154+
**Problem**: "No shell found" or quote/escape errors on Windows
155+
**Solution**: Use proper quote formatting for Windows command line:
156+
```bash
157+
# ❌ Wrong - excessive escaping or nested quotes
158+
ant -buildfile=\"d:\work\script-runner\" -Dwebroot=\"D:\work\project\"
159+
160+
# ✅ Correct - Windows Command Prompt (no quotes needed for paths without spaces)
161+
ant -buildfile=d:\work\script-runner\build.xml -Dwebroot=D:\work\project -Dexecute=/test.cfm
162+
163+
# ✅ Correct - Windows with spaces in paths (use quotes around entire parameter)
164+
ant "-buildfile=C:\Program Files\script-runner\build.xml" "-Dwebroot=C:\My Projects\test" -Dexecute=/test.cfm
165+
166+
# ✅ Correct - PowerShell (use single quotes to avoid variable expansion)
167+
ant -buildfile='d:\work\script-runner\build.xml' -Dwebroot='D:\work\project' -Dexecute='/test.cfm'
168+
```
31169
32-
`ant -DluceeVersion="6.0.0.95-SNAPSHOT" -DextensionDir="C:\work\lucee-extensions\extension-hibernate\dist"`
170+
**Important Windows Tips:**
171+
- When using `-buildfile` with a directory, add `\build.xml` explicitly
172+
- Avoid escaped quotes (`\"`) - they're usually not needed
173+
- Use forward slashes (`/`) or double backslashes (`\\`) in scripts to avoid escape issues
174+
- In batch files, use `%%` instead of `%` for variables
33175
34176
If no webroot is specfied, you can run the provided debug script, to see which extensions are available and all the env / sys properties
35177
36178
`ant -buildfile="C:\work\script-runner" -Dexecute="/debug.cfm"`
37179
38-
`ant -buildfile="C:\work\script-runner" -Dexecute="/debug.cfm" -DluceeVersion="light-6.0.0.95-SNAPSHOT"` (`light` has no bundled extensions, `zero` has no extension or admin)
180+
`ant -buildfile="C:\work\script-runner" -Dexecute="/debug.cfm" -DluceeVersion="light-6.2.2.91"` (`light` has no bundled extensions, `zero` has no extension or admin)
39181
40182
## As a GitHub Action
41183
@@ -72,6 +214,7 @@ To use as a GitHub Action, to run the PDF tests after building the PDF Extension
72214
debugger: true (optional) runs with java debugging enabled on port 5000
73215
preCleanup: true (purges Lucee working directory before starting)
74216
postCleanup: true (purges Lucee working directory after finishing)
217+
uniqueWorkingDir: true (optional) uses unique working directory for concurrent execution
75218
env:
76219
testLabels: pdf
77220
testAdditional: ${{ github.workspace }}/tests
@@ -108,5 +251,5 @@ pipelines:
108251
- git clone https://github.com/lucee/lucee
109252
- export testLabels="PDF"
110253
- echo $testLabels
111-
- ant -buildfile script-runner/build.xml -DluceeVersion="light-6.0.0.152-SNAPSHOT" -Dwebroot="$BITBUCKET_CLONE_DIR/lucee/test" -DextensionDir="$BITBUCKET_CLONE_DIR/dist" -Dexecute="/bootstrap-tests.cfm" -DtestAdditional="$BITBUCKET_CLONE_DIR/tests"
254+
- ant -buildfile script-runner/build.xml -DluceeVersion="light-6.2.2.91" -Dwebroot="$BITBUCKET_CLONE_DIR/lucee/test" -DextensionDir="$BITBUCKET_CLONE_DIR/dist" -Dexecute="/bootstrap-tests.cfm" -DtestAdditional="$BITBUCKET_CLONE_DIR/tests"
112255
```

action.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: 'Lucee Script Runner'
22
description: 'Run Lucee via the command line'
33
inputs:
44
luceeVersion:
5-
description: Lucee Version to run, i.e. "light-6.0.3.1", "5.4.6.9", "zero-6.0.3.1"
5+
description: Lucee Version to run, i.e. "light-6.2.2.91", "5.4.6.9", "zero-6.2.2.91"
66
required: true
77
luceeVersionQuery:
88
description: Lucee Version Query to run (overrides luceeVersion, i.e. "5.4/stable/light", "6.1/snapshot/jar", "6/stable/zero" )
@@ -37,6 +37,9 @@ inputs:
3737
postCleanup:
3838
description: purge the directory Lucee is deployed into after finishing
3939
default: "true"
40+
uniqueWorkingDir:
41+
description: 'Working directory mode: "false" (default temp/lucee), "true" (auto-generate unique), or custom path (e.g., "/custom/work")'
42+
default: "false"
4043
runs:
4144
using: "composite"
4245
steps:
@@ -56,7 +59,8 @@ runs:
5659
-Dextensions="${{ inputs.extensions }}" -DextensionDir="${{ inputs.extensionDir }}" \
5760
-Dcompile="${{ inputs.compile }}" -Ddebugger="${{ inputs.debugger }}" \
5861
-DluceeCFConfig="${{inputs.luceeCFConfig}}" \
59-
-DpreCleanup="${{inputs.preCleanup}}" -DpostCleanup="${{inputs.postCleanup}}"
62+
-DpreCleanup="${{inputs.preCleanup}}" -DpostCleanup="${{inputs.postCleanup}}" \
63+
-DuniqueWorkingDir="${{inputs.uniqueWorkingDir}}"
6064
shell: bash
6165
- if: runner.os == 'Windows'
6266
run: |
@@ -74,5 +78,6 @@ runs:
7478
-Dwebroot="${{ inputs.webroot }}" -Dexecute="${{ inputs.execute }}" -Dextensions="${{ inputs.extensions }}" ^
7579
-DextensionDir="${{ inputs.extensionDir }}" -Dcompile="${{ inputs.compile }}" ^
7680
-Ddebugger="${{ inputs.debugger }}" -DluceeCFConfig="${{inputs.luceeCFConfig}}" ^
77-
-DpreCleanup="${{inputs.preCleanup}}" -DpostCleanup="${{inputs.postCleanup}}"
81+
-DpreCleanup="${{inputs.preCleanup}}" -DpostCleanup="${{inputs.postCleanup}}" ^
82+
-DuniqueWorkingDir="${{inputs.uniqueWorkingDir}}"
7883
shell: cmd

build-run-cfml.xml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<project default="all" basedir="." name="run-cfml">
3+
4+
<!-- Protection: This file should only be called from build.xml -->
5+
<fail message="ERROR: build-run-cfml.xml should not be run directly! Use build.xml instead.">
6+
<condition>
7+
<not>
8+
<isset property="lucee.base.dir"/>
9+
</not>
10+
</condition>
11+
</fail>
12+
313
<macrodef name="echots">
414
<attribute name="message"/>
515
<sequential>
@@ -163,7 +173,7 @@
163173
164174
try {
165175
if ( executeScriptByInclude eq "true"){
166-
include template="#execute#";
176+
//include template="#execute#";
167177
} else {
168178
_internalRequest(
169179
template = execute,

0 commit comments

Comments
 (0)