-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathremote.sh
executable file
·58 lines (50 loc) · 1.11 KB
/
remote.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env bash
set -e
# 服务端脚本 # rvm 环境
source ~/.profile
export RAILS_ENV=production
project=$1
compress=${project}.tar.gz
if [[ -d ${project} ]];then
echo "服务器已存在该项目,开始更新...."
cd ${project}
if [[ -f ${project}/shared/pids/puma.pid ]];then
pid=`cat shared/pids/puma.pid`
if [[ -d /proc/${pid} ]];then
kill ${pid}
fi
fi
if [[ -f ${project}/shared/pids/sidekiq.pid ]];then
pid=`cat shared/pids/sidekiq.pid`
if [[ -d /proc/${pid} ]];then
kill ${pid}
fi
fi
cd ..
# 删除存在的项目
rm -rf ${project}
fi
# 解压
echo "开始解压...."
tar xzf ${compress}
rm -rf ${compress}
cd ${project}
# ruby 依赖
echo "安装 Ruby 依赖...."
bundle install > /dev/null
# 创建数据库
bundle exec rake db:create
# 数据库迁移
echo "运行数据库迁移...."
bundle exec rails db:migrate > /dev/null
# 更新 cron jobs
whenever -i
# 创建必要文件夹
mkdir -p shared/log shared/pids shared/sockets
# 运行服务器
echo "启动服务器...."
puma
# 启动 sidekiq
echo "启动 sidekiq"
bundle exec sidekiq -d -e production
echo "服务器启动成功"