depr -cfg flag & change to -c

This commit is contained in:
wjqserver 2025-03-29 12:01:46 +08:00
parent 153b544024
commit 4b37c6bb2b
7 changed files with 34 additions and 12 deletions

View file

@ -19,6 +19,7 @@ ForceH2C = false
[shell] [shell]
editor = false editor = false
rewriteAPI = false
[pages] [pages]
mode = "internal" # "internal" or "external" mode = "internal" # "internal" or "external"

View file

@ -3,7 +3,7 @@ Description=Github Proxy Service
After=network.target After=network.target
[Service] [Service]
ExecStart=/bin/bash -c '/usr/local/ghproxy/ghproxy -cfg /usr/local/ghproxy/config/config.toml > /usr/local/ghproxy/log/run.log 2>&1' ExecStart=/bin/bash -c '/usr/local/ghproxy/ghproxy -c /usr/local/ghproxy/config/config.toml > /usr/local/ghproxy/log/run.log 2>&1'
WorkingDirectory=/usr/local/ghproxy WorkingDirectory=/usr/local/ghproxy
Restart=always Restart=always
User=root User=root

View file

@ -123,7 +123,7 @@ Description=Github Proxy Service
After=network.target After=network.target
[Service] [Service]
ExecStart=/bin/bash -c '$ghproxy_dir/ghproxy -cfg $ghproxy_dir/config/config.toml > $ghproxy_dir/log/run.log 2>&1' ExecStart=/bin/bash -c '$ghproxy_dir/ghproxy -c $ghproxy_dir/config/config.toml > $ghproxy_dir/log/run.log 2>&1'
WorkingDirectory=$ghproxy_dir WorkingDirectory=$ghproxy_dir
Restart=always Restart=always
User=root User=root

View file

@ -123,7 +123,7 @@ Description=Github Proxy Service
After=network.target After=network.target
[Service] [Service]
ExecStart=/bin/bash -c '$ghproxy_dir/ghproxy -cfg $ghproxy_dir/config/config.toml > $ghproxy_dir/log/run.log 2>&1' ExecStart=/bin/bash -c '$ghproxy_dir/ghproxy -c $ghproxy_dir/config/config.toml > $ghproxy_dir/log/run.log 2>&1'
WorkingDirectory=$ghproxy_dir WorkingDirectory=$ghproxy_dir
Restart=always Restart=always
User=root User=root

View file

@ -36,12 +36,18 @@ FROM alpine:latest
RUN apk add --no-cache curl RUN apk add --no-cache curl
ARG USER=WJQSERVER-STUDIO
ARG REPO=ghproxy
ARG BRANCH=v3
ARG APPLICATION=ghproxy
ARG TARGETOS
ARG TARGETARCH
ARG TARGETPLATFORM
COPY --from=builder /data/www /data/www COPY --from=builder /data/www /data/www
COPY --from=builder /data/${APPLICATION} /data/${APPLICATION} COPY --from=builder /data/${APPLICATION} /data/${APPLICATION}
COPY --from=builder /usr/local/bin/init.sh /usr/local/bin/init.sh
# 权限 # 权限
RUN chmod +x /data/${APPLICATION}/${APPLICATION} RUN chmod +x /data/${APPLICATION}/${APPLICATION}
RUN chmod +x /usr/local/bin/init.sh
CMD ["/usr/local/bin/init.sh"] CMD ["/data/ghproxy/ghproxy"]

View file

@ -36,14 +36,20 @@ FROM alpine:latest
RUN apk add --no-cache curl RUN apk add --no-cache curl
ARG USER=WJQSERVER-STUDIO
ARG REPO=ghproxy
ARG BRANCH=v3
ARG APPLICATION=ghproxy
ARG TARGETOS
ARG TARGETARCH
ARG TARGETPLATFORM
COPY --from=builder /data/www /data/www COPY --from=builder /data/www /data/www
#COPY --from=builder /data/caddy /data/caddy
COPY --from=builder /data/${APPLICATION} /data/${APPLICATION} COPY --from=builder /data/${APPLICATION} /data/${APPLICATION}
COPY --from=builder /usr/local/bin/init.sh /usr/local/bin/init.sh
# 权限 # 权限
RUN chmod +x /data/${APPLICATION}/${APPLICATION} RUN chmod +x /data/${APPLICATION}/${APPLICATION}
RUN chmod +x /usr/local/bin/init.sh
CMD ["/usr/local/bin/init.sh"] CMD ["/data/ghproxy/ghproxy"]

13
main.go
View file

@ -63,10 +63,19 @@ var (
) )
func readFlag() { func readFlag() {
flag.StringVar(&cfgfile, "cfg", configfile, "config file path") flag.StringVar(&cfgfile, "c", configfile, "config file path")
flag.Func("cfg", "exit", func(s string) error {
// 被弃用的flag, fail退出
fmt.Printf("\n")
fmt.Println("[ERROR] cfg flag is deprecated, please use -c instead")
fmt.Printf("\n")
flag.Usage()
os.Exit(1)
return nil
})
flag.BoolVar(&showVersion, "v", false, "show version and exit") // 添加-v标志 flag.BoolVar(&showVersion, "v", false, "show version and exit") // 添加-v标志
flag.BoolVar(&showHelp, "h", false, "show help message and exit") // 添加-h标志 flag.BoolVar(&showHelp, "h", false, "show help message and exit") // 添加-h标志
// 捕获未定义的 flag // 捕获未定义的 flag
flag.Usage = func() { flag.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0]) fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0])