Fix systemd service startup issues

- Updated test-and-start.sh to work with systemd services
- Added proper node executable path detection
- Fixed issue with shebang line in startup script
- Updated service module to use absolute paths correctly
- Improved robustness of startup script with better error handling

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-03-07 10:11:20 +00:00
parent 35420335d7
commit 852de32907
2 changed files with 44 additions and 6 deletions

View File

@@ -82,9 +82,28 @@ if [ ! -f "$DATA_DIR/rss-items.json" ]; then
echo "[]" > "$DATA_DIR/rss-items.json"
fi
# Find the node executable path
NODE_PATH=$(which node 2>/dev/null)
if [ -z "$NODE_PATH" ]; then
# If node is not in PATH, try common locations
for path in /usr/bin/node /usr/local/bin/node /opt/node/bin/node /usr/lib/node; do
if [ -x "$path" ]; then
NODE_PATH="$path"
break
fi
done
# If we still can't find node, use the default path
if [ -z "$NODE_PATH" ]; then
NODE_PATH="/usr/bin/node"
echo "Warning: Node.js not found in PATH, using default path: $NODE_PATH"
fi
fi
# Start the application
cd "$APP_DIR" || { echo "Failed to change to application directory"; exit 1; }
node server.js
echo "Starting node.js application with: $NODE_PATH $APP_DIR/server.js"
exec "$NODE_PATH" "$APP_DIR/server.js"
EOF
chmod +x "$TEST_START_SCRIPT"