# omc_api

OMC 后端

## 简单运行

```bash
cd /home/manager/omc_api

go env -w CGO_ENABLED='1'
go env -w GOPROXY=https://goproxy.cn,direct
go mod download

cd restagent/
# 打包命名 omcDevApp
go build -ldflags="-s -w" -o omcDevApp

# 启动
./omcDevApp -c ./etc/restconf.yaml --env local

nohup ./omcDevApp -c ./etc/restconf.yaml > ./dev.log 2>&1 &

# 查找进程并杀死
kill -9 $(ps aux | grep "omcDevApp" | grep -v grep | awk '{print $2}')
ps aux | grep omcDevApp
```

## 脚本

```bash
ps aux | grep "omcDevApp"

process_id=$(ps aux | grep "omcDevApp" | grep -v grep | awk '{print $2}')
if [ -n "$process_id" ]; then
  kill -9 "$process_id"
else
  echo "未找到匹配的进程"
fi

go version
go mod download

cd restagent/
go build -ldflags="-s -w" -o omcDevApp

BUILD_ID=dontKillMe
nohup ./omcDevApp -c ./dev.yaml > ./dev.log 2>&1 &
echo ok

```

## Docker

```bash
docker build --build-arg VERSION=241101 -t omc:2.241101 .

docker run -it omc:2.241101 sh

-v /var/log/omc
-v /etc/nginx
-v /usr/local/omc/etc
-v /usr/local/omc/static
-v /usr/local/omc/upload
-p 33022:22 \

docker run -d \
--privileged=true \
--restart=always \
-e TZ="Asia/Shanghai" \
-m 512M \
--name omc_001 \
omc:2.241101
```
