Coder Social home page Coder Social logo

market_monitor's Introduction

💂‍♂️ market_monitor

gopher

克隆项目

$ git clone https://github.com/ErikJiang/market_monitor.git

单独运行项目

进入应用服务源码目录:

$ cd market_monitor/app/src/

目录结构:

app/src/:
    ├─config/       # 配置文件目录(运行前需要调整database、redis等参数配置)
    ├─controller/   # 控制器层目录
    ├─docs/         # 接口文档 Swagger 生成目录
    ├─extend/       # 扩展模块目录
    ├─middleware/   # 中间件目录
    ├─models/       # 数据模型层
    ├─public/       # 静态资源目录
    ├─router/       # 路由目录
    ├─schedule/     # 定时任务目录
    ├─service/      # 服务层目录
    ├─templates/    # 视图模板层目录
    ├─go.mod        # 包管理文件
    ├─go.sum        # 依赖包版本哈希文件
    └─main.go       # 运行入口main文件

自主创建数据库:

CREATE DATABASE db_monitor DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;

启动服务:

$ go run main.go

运行过程若出现下载 module 失败,或 build 缓慢,可尝试设置GOPROXY环境变量:

$ export GOPROXY=https://goproxy.io

运行后访问:http://localhost:8000/swagger/index.html,查看接口文档;

Docker 运行构建

进入项目根目录:

$ cd market_monitor/

主目录结构:

market_monitor/
    ├─docker-compose.yaml   # compose 镜像服务构建文件
    ├─app                   # monitor 应用服务
    │  ├─src/               # 源码目录
    │  └─dockerfile         # docker 镜像构建文件
    ├─mysql                 # mysql 数据服务
    │  ├─conf
    │  │  ├─conf.d/         # 服务自定义配置(字符编码等)
    │  │  └─init.d/         # 初始化SQL脚本(建库语句)及用户权限设置
    │  ├─data/              # 数据文件挂载目录
    │  └─logs/              # 日志目录
    └─redis                 # redis 缓存服务
        ├─conf/             # 缓存服务自定义配置(密码等)
        └─data/             # 数据文件挂载目录

由于 app/ 下的 dockerfile 指定 golang 编译所需依赖从 app/src/vendor/ 目录中读取,故需要提前准备编译所需依赖:

$ cd app/src/
$ go mod vendor

最后再回到项目根目录,使用 docker compose 以后台启动方式构建容器服务:

$ docker-compose up -d

简明教程请见: Wiki

market_monitor's People

Contributors

erikjiang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

market_monitor's Issues

docker mysql status Restarting

docker-compose up -d
执行完之后 mysql的status 总是Restasting
2cefca85bca9 mysql:8.0.13 "docker-entrypoint.s…" 3 minutes ago Restarting (1) 54 seconds ago m_mysql
执行docker logs 2cefca85bca9
如下:2019-11-12T07:28:56.019652Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
原因是映射的/market_monitor/mysql/data/ 文件夹下有个README.md
删除后 恢复正常

单独运行获取依赖出错

使用go run main.go提示
cannot find package "github.com/JiangInk/market_monitor/extend/conf" in any of:
使用dep init -v提示
init failed: unable to solve the dependency graph: Solving failure: No versions of github.com/JiangInk/market_monitor met constraints:

go版本 1.11.1
系统macOS

请问咋解决呢??

grom:table_options , grom 应该改为 gorm

app/src/models/dbSetup.go
DB.Set(
"grom:table_options",
"ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci",
).AutoMigrate(&User{}, &Task{})

grom:table_options , grom 应该改为 gorm

startup bug by mysql err

$ docker logs -f m_mysql
logs as followings:
2019-03-25T13:49:07.305063Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting. 2019-03-25T13:49:07.305261Z 0 [ERROR] [MY-013236] [Server] Newly created data directory /var/lib/mysql/ is unusable. You can safely remove it. 2019-03-25T13:49:07.305293Z 0 [ERROR] [MY-010119] [Server] Aborting
bugfix:
$ rm -rf market_monitor/mysql/data/*
$ docker-compose restart

done!!!

SwaggerUIBundle is not defined

Failed to load resource: the server responded with a status of 404 (Not Found)
index.html:75 Uncaught ReferenceError: SwaggerUIBundle is not defined
at window.onload (index.html:75)
{6ECE89E3-5F8F-436B-A3BA-14EDDAA05FDD}_20190924102128

求教程

大佬能不能出个教程,我们这些菜鸟看上去好吃力手动狗头

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.