1.在项目的根目录下,按住shift+鼠标右键打开PowerShell
注意:按顺序执行即可,wms是项目名称
cmd
set GOOS=linux
go build wms
2.将项目打包放到Linux系统上
3.找到wcs.service自启动文件的目录,然后右键终端,执行下面命令:
sudo vi /lib/systemd/system/wms.service
将wcs.service的内容粘贴进去,输入 i 进行插入,更改一下项目名称;
[Unit]
Description=wms
After=network-online.target
Wants=network-online.target
[Service]
User=being
Group=being
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
WorkingDirectory=/home/being/wms
ExecStart=/home/being/wms/wms
Restart=always
RestartSec=60s
# file size
LimitFSIZE=infinity
# cpu time
LimitCPU=infinity
# virtual memory size
LimitAS=infinity
# open files
LimitNOFILE=100000000
# processes/threads
LimitNPROC=100000000
# locked memory
LimitMEMLOCK=infinity
# total threads (user+kernel)
TasksMax=infinity
TasksAccounting=false
LimitCORE=infinity
# 禁用标准输出
#StandardOutput=null
# 禁用错误输出
#StandardError=null
[Install]
WantedBy=multi-user.target
4.输入Esc,输入:wq 按回车键
5. 生效自启动文件
sudo chown -R root:root /lib/systemd/system/wms.service
sudo chmod 755 /etc/systemd/system/wms.service
sudo systemctl enable wms
6.输入命令启起wms 启动:start
sudo systemctl restart wms
7.输入命令查看是否启动成功
sudo systemctl status wms