-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d26f4f7
commit b801d29
Showing
6 changed files
with
94 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
FROM golang:1.22-alpine AS builder | ||
|
||
LABEL stage=gobuilder \ | ||
mainatiner=https://github.com/xgzlucario/rotom | ||
|
||
ENV CGO_ENABLED 0 | ||
ENV GOPROXY https://goproxy.cn,direct | ||
|
||
WORKDIR /build | ||
|
||
COPY . . | ||
|
||
RUN go build -o rotom . | ||
|
||
FROM alpine:latest | ||
|
||
ENV TZ Asia/Shanghai | ||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories | ||
RUN apk add --no-cache ca-certificates tzdata && \ | ||
update-ca-certificates | ||
|
||
RUN apk --no-cache add redis | ||
|
||
VOLUME /data | ||
WORKDIR /data | ||
|
||
COPY --from=builder /build/rotom /data/rotom | ||
COPY config.json /etc/rotom/config.json | ||
|
||
EXPOSE 6969 | ||
|
||
CMD ["./rotom", "-config", "/etc/rotom/config.json"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,36 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"log" | ||
"net/http" | ||
_ "net/http/pprof" | ||
) | ||
|
||
func debug() { | ||
func runDebug() { | ||
go http.ListenAndServe(":6060", nil) | ||
} | ||
|
||
func main() { | ||
var err error | ||
config, err := LoadConfig("config.json") | ||
var path string | ||
var debug bool | ||
|
||
flag.StringVar(&path, "config", "config.json", "default config file path.") | ||
flag.BoolVar(&debug, "debug", false, "run with debug mode.") | ||
flag.Parse() | ||
|
||
log.Printf("cmd arguments: config=%s, debug=%v", path, debug) | ||
|
||
config, err := LoadConfig(path) | ||
if err != nil { | ||
log.Panicf("load config error: %v\n", err) | ||
} | ||
if err = InitDB(config); err != nil { | ||
log.Panicf("init db error: %v\n", err) | ||
} | ||
debug() | ||
if debug { | ||
runDebug() | ||
} | ||
server.config = config | ||
server.RunServe() | ||
} |