做图服务器源码已出
2017-06-10 本文已影响1332人
Lupino
阅读过 写一个高端做图服务器 一定很好奇这么高端的做图服务器是什么样子的。
现在代码出来了,可以一睹芳容。

编译
老样子我们用 git
将其 clone
下来,然后通过 stack
编译。
git clone https://github.com/Lupino/process-image.git
cd process-image
mkdir bin
echo 'local-bin-path: bin' >> stack.yaml
stack build
stack install
stack install share-fs-server
这个项目有部分组件是使用 go
写的,我们依然需要编译。
export GOPATH=`pwd`
cd app
go get -d
go build upload-file.go
mv upload-file ../bin
cd ..
go get github.com/Lupino/periodic/cmd/periodic
运行
首先申请一个 阿里云储存的 accessKey
和 accessID
,用于上传用,上传组件也可以自己写。
./bin/share-fs-server -H 127.0.0.1 -p 8080 --path share-fs
./bin/periodic -d -H tcp://127.0.0.1:5000
./bin/process-image config.yml
./bin/upload-file -periodic tcp://127.0.0.1:5000 -thread 10 -share-fs-host http://127.0.0.1:8080 -bucket youbucket -accessKey youkey -accessID youid
测试
拿一张图片来测试一下
curl -XPUT -F @icon.png http://127.0.0.1:8080/file/icon.png
echo icon.png | ./bin/submit-image -H 127.0.0.1 -P 5000 -f upload-next-guetzli,resize-image-fw500,resize-image-fw192,resize-image-fw64
结语
欢迎读者们入坑,pull request
。
项目地址: https://github.com/Lupino/process-image
如果觉得文章好,对你有帮助就来关注我吧。