-
Notifications
You must be signed in to change notification settings - Fork 1
/
auto-pull.sh
34 lines (30 loc) · 973 Bytes
/
auto-pull.sh
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
#!/bin/bash
# get the status of the repository.
cd /home/BunJs_In_Production/
state=$(git pull --dry-run 2>&1)
# get the pm2 installation status.
pm2_state=$(which pm2 2>&1)
# check the state of the repository.
if [$state == ""] # check the state of git pull is empty or not.
then
echo "Not Want to be update!"
else
echo "Update!"
git pull # Update the repository.
if [$pm2_state == ""] # check the state of the pm2 install empty or not.
then
echo "pm2 not install!"
npm install -g pm2 # install pm2
sleep 20
cd /home/BunJs_In_Production/ # change directory.
sleep 20
bun install # insall all bun dependency
sleep 20
export PORT=3000 # assign env port
pm2 start bun --name "bun_in_production" -- start
else
pm2 restart bun_in_production # restart if the update done.
fi
fi
# We run this shell script by the use cron task.
# Task run at every minutes: * * * * *