[inner] bug
这样正确
command: ["sh", "-c", "mysql -h${DC_DB_HOST} -uroot -p${MYSQL_ROOT_PASSWORD} ${MYSQL_DATABASE} < ./db/sql/latest_dump.sql"] 这样错误
command: ["mysql -h${DC_DB_HOST} -uroot -p${MYSQL_ROOT_PASSWORD} ${MYSQL_DATABASE} < ./db/sql/latest_dump.sql"] 这样也错误
command: "mysql -h${DC_DB_HOST} -uroot -p${MYSQL_ROOT_PASSWORD} ${MYSQL_DATABASE} < ./db/sql/latest_dump.sql"
makefile:
first step you should build a file name xxx.sh
and then you should make it can execute use command "chomd +x xxx.sh"
reference: http://tsov.net/sh-script-syntax/
rsync:
local to remote :
rsync -avz ./db root@xxxx:/root/
and then it will create a dirctory like /root/db
and -a means recur send document
and -v means show in detils
and -z means zip it to transport
--------------
remote to local
rsync -avz root@xxxx:/root/db .
and it will auto craete dictory in local like ./db
pay attion:
if you have a local file name xxx.sh and remote didn`t, it nothing happend
if you have a local file name xxx.sh and remote also but their different.
1、remote to local and then the local file will replace by the remote file
2、local to remove and then the remote file will replace by the local file
reference: http://man.linuxde.net/rsync
Dockerfile
* if you use ./server/main to start the server and then your .gtml file shoule put on the database-work dirctory beause that is the 相对目录
也就是相对目录是相对于你运行的路径????有待验证
and then the dockerfile must use ./
FROM golang:1.9.-alpine3. COPY . $GOPATH/src/database-work WORKDIR $GOPATH/src/database-work/server RUN go build -o main main.go ENTRYPOINT ["./main"] # must use ./main
一般你的dockerfile会这样写,需要写上workdir,但是由于你的.go往往会有"github.com/xxx/xxx"
所以被迫你的dockerfile的workdir也就是你现在工程的workdir了
shell file
* in the first letter can not get space
#!/bin/bash 不能有空格,在#和!中
golang -- flag
每一个flag只能解析一次,res := flag.String("onlyone", default_value, dafault_use)
然后用go run main.go -onlyone 5是可以的
go run main.go --onlyone 5也是可以的
如果是bool,直接go run main.go -boolvalue就可以认为是true
word && wordint不冲突,都可以用
// [_Command-line flags_](http://en.wikipedia.org/wiki/Command-line_interface#Command-line_option)
// are a common way to specify options for command-line
// programs. For example, in `wc -l` the `-l` is a
// command-line flag. package main // Go provides a `flag` package supporting basic
// command-line flag parsing. We'll use this package to
// implement our example command-line program.
import "flag"
import "fmt" func main() { // Basic flag declarations are available for string,
// integer, and boolean options. Here we declare a
// string flag `word` with a default value `"foo"`
// and a short description. This `flag.String` function
// returns a string pointer (not a string value);
// we'll see how to use this pointer below.
wordPtr := flag.String("word", "default_word", "a string") // This declares `numb` and `fork` flags, using a
// similar approach to the `word` flag.
numbPtr := flag.Int("wordnumb", , "an int"). // 这样也可以,前缀相同
// nextPtr := flag.Int("numb", 0, "an int")
boolPtr := flag.Bool("fork", false, "a bool") // It's also possible to declare an option that uses an
// existing var declared elsewhere in the program.
// Note that we need to pass in a pointer to the flag
// declaration function.
var svar string
flag.StringVar(&svar, "svar", "defalut_var", "a string var") // Once all flags are declared, call `flag.Parse()`
// to execute the command-line parsing.
flag.Parse() // Here we'll just dump out the parsed options and
// any trailing positional arguments. Note that we
// need to dereference the pointers with e.g. `*wordPtr`
// to get the actual option values.
fmt.Println("word:", *wordPtr)
fmt.Println("numb:", *numbPtr)
fmt.Println("fork:", *boolPtr)
// fmt.Println("next:", *nextPtr)
fmt.Println("svar:", svar)
fmt.Println("tail:", flag.Args())
}
在shell文件中写一个,自动生成 时间+名字的文件
首先肯定是用touch命令,然后的话,我写了这样
function migrate() {
version=`date +%s`
if [ ${defaultname}x == ""x ]
then defaultname="defaultname"
fi
touch ./db/migrations/${version}_${defaultname}.up.sql
touch ./db/migrations/${version}_${defaultname}.down.sql
}
直接在terminal中用db.sh migrate name 是可以的。但是去到make migrate name就不行了。不知为何
然后说说那个判定。首先肯定要fi结尾。。。。
然后 https://blog.csdn.net/goodlixueyong/article/details/6564591
具体就是说我的$defaultname可能木有值吧,然后就变成了 == "defaultname"
也就是左边没有了,所以不行。然后同时加个其他字符就好了。
最后说说那个参数,defaultname,只能在外面写,不能去到某一个函数里写哦。
在docker-compose里调用shell文件
dbrestore:
image: mysql:5.7
environment:
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
- DC_DB_HOST=${DC_DB_HOST}
- DC_DB_SSL_MODE=${DC_DB_SSL_MODE}
- MYSQL_DATABASE=${MYSQL_DATABASE}
volumes:
- ../db:/db
- ../tools:/tools
depends_on:
- db
links:
- db
command: "./tools/deploy.sh dbrestore"
.env文件是给docker-compose文件用的,docker-compose里每一个enviroment才是给docerfile或者外面那些shell文件用的
如果不加globlelock,那么100个相同的id进来了,就GG
如果加了,相同的id会被锁住,让一个id先进行成功了,解锁了,然后需要再判断一次,然后就会发现已经存在了。
package seq import (
"sync" "github.com/sundayfun/daycam-server/db"
"github.com/sundayfun/daycam-server/db/model"
) // TODO: fix temp seq id var (
userMutex = make(map[uint64]*sync.Mutex)
existUser = make(map[uint64]uint64)
lock = &sync.Mutex{}
) const (
base =
) func init() {
} func whetherExist(uid uint64) uint64 {
if seq, ok := existUser[uid]; ok {
userMutex[uid].Lock()
defer userMutex[uid].Unlock() existUser[uid] = seq +
return seq
} return // zero refer to does not exist
} func NextSequenceIDByUser(uid uint64) uint64 { seq := whetherExist(uid)
if seq != { // user exist
return seq
} lock.Lock()
defer lock.Unlock() seq = whetherExist(uid)
if seq != { // user exist
return seq
} // first time to start main.go userMutex[uid] = &sync.Mutex{}
userMutex[uid].Lock()
defer userMutex[uid].Unlock() seq := model.LatestSeqByUser(db.GlobalDB, uid) existUser[uid] = seq +
return seq +
}
[inner] bug的更多相关文章
- Tomcat一个BUG造成CLOSE_WAIT
之前应该提过,我们线上架构整体重新架设了,应用层面使用的是Spring Boot,前段日子因为一些第三方的原因,略有些匆忙的提前开始线上的内测了.然后运维发现了个问题,服务器的HTTPS端口有大量的C ...
- a标签点击跳转失效--IE6、7的奇葩bug
一般运用a标签包含img去实现点击图片跳转的功能,这是前端经常要用到的东西. 今天遇到个神奇的bug:如果在img上再包裹一层div,而且div设置了width和height,则图片区域点击时,无任何 ...
- 关于 Chrome 浏览器中 onresize 事件的 Bug
我在写插件时用到了 onresize 事件,在反复地测试后发现该事件在 Chrome 及 Opera(内核基本与 Chrome 相同,以下统称 Chrome)浏览器打开时就会执行,这种情况也许不能算作 ...
- Chrome出了个小bug:论如何在Chrome下劫持原生只读对象
Chrome出了个小bug:论如何在Chrome下劫持原生只读对象 概述 众所周知,虽然JavaScript是个很灵活的语言,浏览器里很多原生的方法都可以随意覆盖或者重写,比如alert.但是为了保证 ...
- 一个粗心的Bug,JSON格式不规范导致AJAX错误
一.事件回放 今天工作时碰到了一个奇怪的问题,这个问题很早很早以前也碰到过,不过没想到过这么久了竟然又栽在这里. 当时正在联调一个项目,由于后端没有提供数据接口,于是我直接本地建立了一个 json ...
- 了不起的 nodejs-TwitterWeb 案例 bug 解决
了不起的nodejs算是一本不错的入门书,不过书中个别案例存在bug,按照书中源码无法做出和书中相同效果,原本兴奋的心情掺杂着些许失落. 现在我们看一下第七章HTTP,一个Twitter Web客户端 ...
- 应该是Angular2的一个bug?
为了应对未来的趋势,及时赶上下一趟互联网技术,我最近也在通过具体项目研究angular2,首先必须要吐槽的是,学习angular2的成本本身不高,但是一堆的工具.配置实在让人 很是焦灼,就像asp.n ...
- 记录一次bug解决过程:数据迁移
一 总结 不擅长语言表达,勤于沟通,多锻炼 调试MyBatis中SQL语法:foreach 问题:缺少关键字VALUES.很遗憾:它的错误报的让人找不着北. 二 BUG描述:MyBatis中批量插入数 ...
- 关于MJRefresh的下拉加载数据bug
当没有更多数据的时候显示NoMoreData 我的理解是先结束刷新再显示没有更多 今天之前一直没发现有问题 贴之前的代码 [self.collectionView reloadData]; [self ...
- [异常特工]android常见bug跟踪
前言 对app的线上bug的收集(友盟.云捕等)有时会得到这样的异常堆栈信息:没有一行代码是有关自身程序代码的.这使得对bug的解决无从下手,根据经验,内存不足OOM,Dialog关闭,ListVie ...
随机推荐
- android 设置颜色的三种方法
1.利于系统自带的颜色类 如TextView1.setTextColor(Android.graphics.Color.RED); 2.数字颜色表示法 TextView1.setTextColor(0 ...
- 在 Java 的反射中,Class.forName 和 ClassLoader 的区别
1. 解释 在java中Class.forName()和ClassLoader都可以对类进行加载.ClassLoader就是遵循双亲委派模型最终调用启动类加载器的类加载器,实现的功能是“通过一个类的全 ...
- Cookies的两种存取方式
我们在使用webview开发时,少不了和cookie打交道,在网页端我这使用的是asp.net开发的,安卓下的cookie和windows平台下还是有些不同的,后来看了看,原来有两种cookie的存取 ...
- 正经学C#_运算符优先级:[c#入门经典]
学了那么多的运算符,终于差不多结束了,现在要说一下 总体的优先级别 高到低的顺序 类别 运算符 结合性 前缀 ++,--,(),+,-,!,~ 从左到右 乘除 * / % 从左到右 加 ...
- P2498 [SDOI2012]拯救小云公主
\(\color{#0066ff}{ 题目描述 }\) 英雄又即将踏上拯救公主的道路-- 这次的拯救目标是--爱和正义的小云公主. 英雄来到boss的洞穴门口,他一下子就懵了,因为面前不只是一只bos ...
- P2866 [USACO06NOV]糟糕的一天Bad Hair Day
题意:给你一个序列,问将序列倒过来后,对于每个点,在再碰到第一个比它大的点之前,有多少比它小的? 求出比它小的个数的和 样例: 610374122 output: 5 倒序后:2 12 4 ...
- 河南省第十一届ACM程序设计竞赛 修路
Problem C: 修路 Time Limit: 3 Sec Memory Limit: 128 MBSubmit: 63 Solved: 22[Submit][Status][Web Boar ...
- springcloud系列六 整合security
一 Eureka注册中心认证: Eureka自带了一个管理界面,如果不加密,所有人都可以进行访问这个地址,这样安全问题就来了,所以需要对其进行加密认证: 那么该如何进行整合呢: 1 在注册中心模块添加 ...
- 微信小程序生成带参二维码
需求:生成小程序中的海报,需要小程序二维码可以使用户保存到本地在朋友圈分享 生成二维码工具类代码如下: package com.aone.foottalk.action.wx.util; import ...
- linux curl命令:curl: (7) couldn't connect to host ?
linux curl命令:curl: (7) couldn't connect to host ? 使用linux命令 curl http://www.test.com 出现如下错误:curl: (7 ...