Skip to content

Commit c189c8f

Browse files
Adds support for overriding the concurrency used in the packaging
process via the SLS_PACKAGE_CONCURRENCY environment variable. Defaults to os.cpus().length if not set. Benefits: - Solve problems running sls in termux and proot environments on android. os.cpus() returns an empty list when running in proot and makes running the framework very difficult for deployments - Allows better control over system resource usage in constrained environments.
1 parent 1003a32 commit c189c8f

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

lib/plugins/package/lib/zip-service.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import archiver from 'archiver'
22
import os from 'os'
3-
import path from 'path'
3+
import path, { parse } from 'path'
44
import crypto from 'crypto'
55
import fs from 'fs'
66
import fsp from 'fs/promises'
@@ -102,9 +102,13 @@ export default {
102102
const normalizedFiles = _.uniq(
103103
files.map((file) => path.normalize(file)),
104104
)
105+
const concurrency = process.env.SLS_PACKAGE_CONCURRENCY ? parseInt(
106+
process.env.SLS_PACKAGE_CONCURRENCY,
107+
10,
108+
) : os.cpus().length
105109

106110
return pMap(normalizedFiles, this.getFileContentAndStat.bind(this), {
107-
concurrency: os.cpus().length,
111+
concurrency,
108112
})
109113
.then((contents) => {
110114
contents

0 commit comments

Comments
 (0)