forked from n8n-io/n8n-nodes-starter
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy-node.sh
More file actions
executable file
·56 lines (42 loc) · 1.51 KB
/
deploy-node.sh
File metadata and controls
executable file
·56 lines (42 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
# This script builds your custom node, deploys it to your local n8n custom nodes folder,
# kills any running n8n process, and restarts it in the background.
set -e
##############################
# Step 0: Get Package Name
##############################
PACKAGE_NAME=$(node -p "require('./package.json').name")
if [ -z "$PACKAGE_NAME" ]; then
echo "Error: Could not determine package name from package.json."
exit 1
fi
# Change this to match where your local n8n setup loads custom nodes from
N8N_CUSTOM_DIR="$HOME/.n8n/custom/$PACKAGE_NAME"
echo "Detected package name: '$PACKAGE_NAME'"
echo "Target deployment directory: '$N8N_CUSTOM_DIR'"
##############################
# Step 1: Build the Node
##############################
echo "Building the node..."
pnpm run build
##############################
# Step 2: Deploy the Build Output
##############################
SOURCE_DIR="./dist"
echo "Deploying build output from '$SOURCE_DIR' to '$N8N_CUSTOM_DIR'..."
rm -rf "$N8N_CUSTOM_DIR"
mkdir -p "$N8N_CUSTOM_DIR"
cp -r "$SOURCE_DIR/"* "$N8N_CUSTOM_DIR/"
echo "Deployment complete."
##############################
# Step 3: Restart n8n
##############################
echo "Restarting n8n..."
# Kill any running n8n processes
pkill -f "n8n" || echo "No running n8n process found."
# Wait briefly to ensure the process has shut down
sleep 2
# Start n8n in the background
# nohup n8n > ~/.n8n/n8n.log 2>&1
nohup bash -c 'source ~/.zshrc && n8n' > ~/.n8n/n8n.log 2>&1 &
echo "n8n restarted. Logs are in ~/.n8n/n8n.log"