Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(nodejs): exit installation if Node.js version is unsupported #1010

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions recipes/newrelic/apm/node/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,30 @@ preInstall:
if [ -z "$ASSERT_NODE_INSTALLED" ] ; then
exit 1
fi

LOWEST_SUPPORTED_MAJOR_NODE_VERSION=16
NODEJS_BINARY_PATH=$(command -v node)
INSTALLED_MAJOR_NODE_VERSION=$($NODEJS_BINARY_PATH -v | awk -F '[^0-9]+' '{ print $2 }')
if [ "$INSTALLED_MAJOR_NODE_VERSION" -lt "$LOWEST_SUPPORTED_MAJOR_NODE_VERSION" ]; then
echo "Error: Node.js version not supported. Please upgrade to the latest supported version." >&2
exit 132
fi

ASSERT_NPM_INSTALLED=$(sudo -i -u $SUDO_USER command -v npm)
if [ -z "$ASSERT_NPM_INSTALLED" ] ; then
exit 2
fi

# Only PM2 is supported at this time
ASSERT_PM2_INSTALLED=$(sudo -i -u $SUDO_USER command -v pm2)
if [ -z "$ASSERT_PM2_INSTALLED" ] ; then
echo "Error: PM2 is required to complete installation." >&2
exit 132
fi

IS_PM2_RUNNING=$(sudo ps aux | grep pm2 | grep -v grep | wc -l)
if [ $IS_PM2_RUNNING -eq 0 ] ; then
echo "Error: PM2 not running. Please start PM2 and retry the installation." >&2
exit 132
fi
exit 0
Expand Down
Loading