This commit is contained in:
alirehmani
2024-05-10 17:01:34 +05:00
parent e74d1d33cd
commit 06b1b99126
6 changed files with 67 additions and 58 deletions

View File

@@ -0,0 +1,32 @@
#!/bin/bash
# Array of known potentially hanging packages
hanging_packages=("xmlhttprequest-ssl@latest" "engine.io-parser@latest")
# Timeout in seconds for each package installation attempt
install_with_timeout() {
package=$1
echo "Attempting to install $package with a timeout of $timeout_duration seconds."
# Start npm install in the background
npm install $package --verbose &> $package.log &
# Get PID of the npm process
pid=$!
# Wait for the npm process to finish or timeout
(sleep $timeout_duration && kill -0 $pid 2>/dev/null && kill -9 $pid && echo "Timeout reached for $package, process killed." && echo $package >> exclude.log) &
waiter_pid=$!
# Wait for the npm process to complete
wait $pid
# Kill the waiter process in case npm finished before the timeout
kill -0 $waiter_pid 2>/dev/null && kill -9 $waiter_pid
}
# Install potentially hanging packages first with a timeout
for package in "${hanging_packages[@]}"; do
install_with_timeout $package
done