Hi,你的发布脚本是怎么样的?

2015-09-15 08:04:37 +08:00
 banxi1988
我昨天写了个简单的发布脚本。

```bash
#!/bin/bash
git pull
dest_tar='cool_project.tar.gz'
dest_dir='/var/www/'
tar zcf $dest_tar cool_project requirements.txt app.py
echo 'tar done'
cp $dest_tar $dest_dir
(cd $dest_dir;tar zxf $dest_tar )
echo 'untar done'
rm $dest_tar
supervisorctl restart cool_project
```

以前的发布脚本工作主要是由 fabric 完成的。
但是使用 fabric 上传整个项目太慢了。
现在改成在服务器 clone 项目,然后再更新发布,虽然也算有一点改进。
但是我感觉还是很 ugly.

求吐槽,求指点。
5011 次点击
所在节点    Python
23 条回复
workwonder
2015-09-15 08:25:24 +08:00
步骤很多余。
我们直接 rsync 增量同步,秒级发布到阿里云。
noahzh
2015-09-15 08:43:09 +08:00
为什么不用 ansible?
kongkongyzt
2015-09-15 08:44:03 +08:00
github/oschina 上面创建私人 repo

配置 git hook 和 server ssh 和 Server 的接口

每次 git push 触发 git hook,git hook 请求 Server 的接口

接口执行 git pull,重启服务器

部署结束
TangMonk
2015-09-15 08:48:14 +08:00
git-deploy 去看看
kikyous
2015-09-15 08:55:15 +08:00
require 'mina/git'
# Basic settings:
# domain - The hostname to SSH to.
# deploy_to - Path to deploy into.
# repository - Git repo to clone from. (needed by mina/git )
# branch - Branch name to deploy. (needed by mina/git )

set :user, 'deploy'
set :domain, 'antesky.com'
set :deploy_to, '/home/deploy/www/AceAttorney'
set :repository, 'git@git.coding.net:plamed/AceAttorney.git'
set :branch, 'master'

set :shared_paths, ['.env', 'storage', 'vendor', 'node_modules', 'public/uploads']

task :environment do
end

# Put any custom mkdir's in here for when `mina setup` is ran.
# For Rails apps, we'll make some of the shared paths that are shared between
# all releases.
task :setup => :environment do
end

desc "Deploys the current version to the server."
task :deploy => :environment do
to :before_hook do
# Put things to run locally before ssh
end
deploy do
# Put things that will set up an empty directory into a fully set-up
# instance of your project.
invoke :'git:clone'
invoke :'deploy:link_shared_paths'

queue 'composer install'
queue 'php artisan migrate'
queue 'php artisan optimize'
queue 'npm install'
queue 'gulp --production'

invoke :'deploy:cleanup'
to :launch do
queue 'composer dumpautoload'
end
end
end
kikyous
2015-09-15 08:56:18 +08:00
rails 项目和 laravel 项目我都用 mina 部署,很方便
bcxx
2015-09-15 09:04:45 +08:00
https://github.com/bcho/flaskr/blob/master/fabfile.py 目前在用的 fabric 脚本,使用 platter 来打包依赖
r00tt
2015-09-15 09:47:27 +08:00
我用 capistrano 简直就是一键,配置好之后 cap production deploy 直接去 git 拉取代码,部署,还可以保留版本,回滚,同时亦可以部署到集群上
zhicheng
2015-09-15 10:00:12 +08:00
fabfile 路过下。
Theo14
2015-09-15 10:06:15 +08:00
rundeck ,你值得拥有
9hills
2015-09-15 10:10:01 +08:00
fabric 也可以做到你这个啊。。
maemual
2015-09-15 10:18:07 +08:00
目测是你的 fabric 用的不对,你写的 fabric 都能做。
shawshank
2015-09-15 11:08:27 +08:00
用 saltstack 管理,一条命令把代码推到所有机器然后重启。在每台机器上都用 git ,感觉速度受网络影响很大。
WildCat
2015-09-15 11:11:20 +08:00
Docker 党何在?
WKPlus
2015-09-15 12:27:52 +08:00
有个疑问,为啥需要先打包再解包?
suckMyballs
2015-09-15 13:02:12 +08:00
@kongkongyzt git pull 完为什么要重启服务器
cosmosz
2015-09-15 13:05:29 +08:00
capistrano RoR
crazyxin1988
2015-09-15 13:05:47 +08:00
用 fabric 直接拉 git 的代码 不行么
为啥要打包啊
gaitana
2015-09-15 13:06:32 +08:00
还用啥 github ,直接 git push 到服务器
kongkongyzt
2015-09-15 13:57:07 +08:00
@suckMyballs 手快打错了-_-||不是重启服务器

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/220742

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX