mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-25 18:06:15 -04:00
legacySupport: Run node 10 with '--experimental_worker' flags (#4392)
* Run node 10 with '--experimental_worker' flags * Use dedicated function to retrieve node/npm program version The goal of this commit is to ensure that any linux based node 10 deployments run with the experimental_worker flag. This flag is required for workers to "work" in node 10. This will not affect other versions of node. This resolves #4335 where Docker would fail due to being based on node 10.
This commit is contained in:
parent
c74b254334
commit
52f8fc9ba3
7 changed files with 98 additions and 63 deletions
|
@ -1,52 +1,11 @@
|
|||
#!/bin/sh
|
||||
|
||||
# minimum required node version
|
||||
REQUIRED_NODE_MAJOR=10
|
||||
REQUIRED_NODE_MINOR=13
|
||||
|
||||
# minimum required npm version
|
||||
REQUIRED_NPM_MAJOR=5
|
||||
REQUIRED_NPM_MINOR=5
|
||||
|
||||
pecho() { printf %s\\n "$*"; }
|
||||
log() { pecho "$@"; }
|
||||
error() { log "ERROR: $@" >&2; }
|
||||
fatal() { error "$@"; exit 1; }
|
||||
is_cmd() { command -v "$@" >/dev/null 2>&1; }
|
||||
|
||||
require_minimal_version() {
|
||||
PROGRAM_LABEL="$1"
|
||||
VERSION_STRING="$2"
|
||||
REQUIRED_MAJOR="$3"
|
||||
REQUIRED_MINOR="$4"
|
||||
|
||||
# Flag -s (--only-delimited on GNU cut) ensures no string is returned
|
||||
# when there is no match
|
||||
DETECTED_MAJOR=$(pecho "$VERSION_STRING" | cut -s -d "." -f 1)
|
||||
DETECTED_MINOR=$(pecho "$VERSION_STRING" | cut -s -d "." -f 2)
|
||||
|
||||
[ -n "$DETECTED_MAJOR" ] || fatal "Cannot extract $PROGRAM_LABEL major version from version string \"$VERSION_STRING\""
|
||||
|
||||
[ -n "$DETECTED_MINOR" ] || fatal "Cannot extract $PROGRAM_LABEL minor version from version string \"$VERSION_STRING\""
|
||||
|
||||
case "$DETECTED_MAJOR" in
|
||||
''|*[!0-9]*)
|
||||
fatal "$PROGRAM_LABEL major version from \"$VERSION_STRING\" is not a number. Detected: \"$DETECTED_MAJOR\""
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$DETECTED_MINOR" in
|
||||
''|*[!0-9]*)
|
||||
fatal "$PROGRAM_LABEL minor version from \"$VERSION_STRING\" is not a number. Detected: \"$DETECTED_MINOR\""
|
||||
esac
|
||||
|
||||
[ "$DETECTED_MAJOR" -gt "$REQUIRED_MAJOR" ] || ([ "$DETECTED_MAJOR" -eq "$REQUIRED_MAJOR" ] && [ "$DETECTED_MINOR" -ge "$REQUIRED_MINOR" ]) \
|
||||
|| fatal "Your $PROGRAM_LABEL version \"$VERSION_STRING\" is too old. $PROGRAM_LABEL $REQUIRED_MAJOR.$REQUIRED_MINOR.x or higher is required."
|
||||
}
|
||||
|
||||
# Move to the folder where ep-lite is installed
|
||||
cd "$(dirname "$0")"/..
|
||||
|
||||
# Source constants and usefull functions
|
||||
. bin/functions.sh
|
||||
|
||||
# Is node installed?
|
||||
# Not checking io.js, default installation creates a symbolic link to node
|
||||
is_cmd node || fatal "Please install node.js ( https://nodejs.org )"
|
||||
|
@ -55,15 +14,10 @@ is_cmd node || fatal "Please install node.js ( https://nodejs.org )"
|
|||
is_cmd npm || fatal "Please install npm ( https://npmjs.org )"
|
||||
|
||||
# Check npm version
|
||||
NPM_VERSION_STRING=$(npm --version)
|
||||
|
||||
require_minimal_version "npm" "$NPM_VERSION_STRING" "$REQUIRED_NPM_MAJOR" "$REQUIRED_NPM_MINOR"
|
||||
require_minimal_version "npm" $(get_program_version "npm") "$REQUIRED_NPM_MAJOR" "$REQUIRED_NPM_MINOR"
|
||||
|
||||
# Check node version
|
||||
NODE_VERSION_STRING=$(node --version)
|
||||
NODE_VERSION_STRING=${NODE_VERSION_STRING#"v"}
|
||||
|
||||
require_minimal_version "nodejs" "$NODE_VERSION_STRING" "$REQUIRED_NODE_MAJOR" "$REQUIRED_NODE_MINOR"
|
||||
require_minimal_version "nodejs" $(get_program_version "node") "$REQUIRED_NODE_MAJOR" "$REQUIRED_NODE_MINOR"
|
||||
|
||||
# Get the name of the settings file
|
||||
settings="settings.json"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue