zoie 533c8d2c61 FIXBUG:用户登录后未获取到pid | 8 місяців тому | |
---|---|---|
configs | 8 місяців тому | |
doc | 8 місяців тому | |
docs | 8 місяців тому | |
internal | 8 місяців тому | |
tools | 8 місяців тому | |
.gitignore | 8 місяців тому | |
Makefile | 8 місяців тому | |
README.md | 8 місяців тому | |
go.mod | 8 місяців тому | |
go.sum | 8 місяців тому | |
main.go | 8 місяців тому |
golang
开发,安装版本>= 1.21Mysql
数据库,安装版本>=make
,将在./cmd
目录下生成对应二进制执行文件(以项目目录名命名)go build -ldflags "-X gogs.baozhida.cn/Cold_Logistic_libs/pkg/contrib/version.Version=1.0 -X gogs.baozhida.cn/Cold_Logistic_libs/pkg/contrib/version.BuildTime=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" -o ./cmd/cclogisticserver/cclogistic_6270 -v ./cmd/cclogisticserver/main.go
Linux运行需要加 GOOS=linux GOARCH=amd64 go bulid
# 项目目录下执行
# 编译
make
# 查看版本
./cmd/<执行文件> version
# 启动api服务
./cmd/<执行文件> run --profile=./configs/test.yml
前后端整体部署时需安装Nginx,相关conf文件参考如下:
upstream cold-logistic {
server <cold-logistic进程ip:port> fail_timeout=0;
}
server {
listen 443 ssl http2;
server_name cold.coldbaozhida.com;
ssl_certificate <xxxxx.cn_bundle.crt>;
ssl_certificate_key <xxxxx..cn.key>;
error_log /var/log/nginx/error_Cold_Logistic.log;
access_log /var/log/nginx/access_Cold_Logistic.log main;
location /iblfront/Cold_Logistic {
if ($request_filename ~* .*\.(?:htm|html|exe|yaml|yml|exe.blockmap|json|mp3)$){
add_header Cache-Control "private, no-store, no-cache, must-revalidate, proxy-revalidate";
}
alias <前端静态文件目录>;
}
location /Cold_Logistic/download/ {
add_header Access-Control-Allow-Methods *;
add_header Access-Control-Max-Age 3600;
add_header Access-Control-Allow-Credentials true;
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Headers
$http_access_control_request_headers;
if ($request_method = OPTIONS){
return 200;
}
# add_header Content-Type "application/octet-stream";
alias <配置文件中storage.localstorage.rootFilepath>;
}
location /Cold_Logistic/api/ {
if ($request_method = OPTIONS){
return 200;
}
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto https;
proxy_redirect off;
proxy_connect_timeout 240;
proxy_send_timeout 240;
proxy_read_timeout 240;
proxy_pass http://Cold_Logistic;
}
}
location / {
client_max_body_size 10m;
add_header Access-Control-Allow-Methods *;
add_header Access-Control-Max-Age 3600;
add_header Access-Control-Allow-Credentials true;
add_header Access-Control-Allow-Origin $http_origin;
add_header Access-Control-Allow-Headers
$http_access_control_request_headers;
if ($request_method = OPTIONS){
return 200;
}
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto https;
proxy_redirect off;
proxy_connect_timeout 240;
proxy_send_timeout 240;
proxy_read_timeout 240;
proxy_pass http://Cold_Logistic;
}
}
# 查看命令帮助信息
./cmd/<二进制执行文件> --help
配置ssh ssh-keygen -t rsa -b 4096 -C "example@example.com" git config --global url."git@gogs.baozhida.cn/Cold_Logistic_libs.git".insteadof "https://gogs.baozhida.cn/zoie/Cold_Logistic_libs.git" go get "gogs.baozhida.cn/zoie/Cold_Logistic_libs.git@master"