Денис

Менеджер по работе с клиентами Sibmain

Mpall

app = Mpall(args) sys.exit(app.run()) if == " main ": main() README.md # mpall - Multi-Process All-in-One Launcher Run commands in parallel across multiple processes with logging, retries, timeouts, and aggregated output. Installation chmod +x mpall.py sudo ln -s $(pwd)/mpall.py /usr/local/bin/mpall </code></pre> <h2>Usage</h2> <pre><code class="language-bash">mpall -c "command placeholder" -r key=value -w 4 </code></pre> <h2>Features</h2> <ul> <li>✅ <strong>Parallel execution</strong> (configurable worker count)</li> <li>✅ <strong>Placeholder replacement</strong> (<code>var</code> in commands)</li> <li>✅ <strong>Retry on failure</strong> (per task)</li> <li>✅ <strong>Timeout protection</strong> (per command)</li> <li>✅ <strong>JSON output</strong> for programmatic analysis</li> <li>✅ <strong>Signal handling</strong> (graceful Ctrl+C)</li> <li>✅ <strong>Logging</strong> (file + console)</li> <li>✅ <strong>Environment variables</strong> injection</li> </ul> <h2>Examples</h2> <h3>Basic parallel runs</h3> <pre><code class="language-bash">mpall -c "echo Hello" -r {} -w 10 </code></pre> <h3>Variable replacement</h3> <pre><code class="language-bash">mpall -c "curl url" -r url=https://api.example.com,method=GET </code></pre> <h3>Multiple replacements</h3> <pre><code class="language-bash">mpall -c "process.py input output" \ -r input=file1.txt,output=out1.txt \ -r input=file2.txt,output=out2.txt </code></pre> <h3>From file</h3> <pre><code class="language-bash">cat > tasks.txt <<EOF input=in1.txt,output=out1.txt input=in2.txt,output=out2.txt EOF

Save as `mpall.py`, make executable, and test: app = Mpall(args) sys

mpall -c "convert.py input output" -f tasks.txt -w 4 </code></pre> <h3>With retries and timeout</h3> <pre><code class="language-bash">mpall -c "flaky_command arg" -r arg=test --retries 3 -t 30 </code></pre> <h3>Save results</h3> <pre><code class="language-bash">mpall -c "test.sh param" -r param=value -o results.json --summary summary.txt </code></pre> <h2>Options</h2> <p>| Option | Description | |--------|-------------| | <code>-c, --command</code> | Command to execute (required) | | <code>-r, --replace</code> | Replacements (key=val pairs) | | <code>-f, --replace-file</code> | File with replacements | | <code>-w, --workers</code> | Parallel workers (default: 4) | | <code>-t, --timeout</code> | Timeout per task in seconds (default: 60) | | <code>--retries</code> | Retry count on failure (default: 0) | | <code>-v, --verbose</code> | Show stdout/stderr | | <code>--log-file</code> | Save logs to file | | <code>-o, --output-json</code> | Export results to JSON | | <code>--output-summary</code> | Export summary to text | | <code>-e, --env</code> | Set environment variable |</p> <h2>Exit Codes</h2> <ul> <li><code>0</code> - All tasks succeeded</li> <li><code>1</code> - One or more tasks failed or invalid arguments</li> </ul> <h2>Use Cases</h2> <ul> <li><strong>Batch processing</strong> (convert images, compress files)</li> <li><strong>Stress testing</strong> (run load tests with different parameters)</li> <li><strong>Data validation</strong> (validate multiple datasets in parallel)</li> <li><strong>API testing</strong> (call multiple endpoints concurrently)</li> <li><strong>Deployment scripts</strong> (deploy to multiple servers)</li> </ul> <h2>License</h2> <p>MIT</p> <pre><code> --- (configurable worker count)&lt

class Logger: """Unified logging handler with file and console output.""" def (self, log_file: Optional[str] = None, verbose: bool = False): self.logger = logging.getLogger("mpall") self.logger.setLevel(logging.DEBUG if verbose else logging.INFO) Retry on failure&lt

# Build command with replacements cmd = [] for arg in args_template: replaced = arg for key, value in replacements.items(): replaced = replaced.replace(f"key", str(value)) cmd.append(replaced)

Подписка