Skip to content

Commit db1f276

Browse files
committed
init
0 parents  commit db1f276

File tree

1,185 files changed

+441166
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,185 files changed

+441166
-0
lines changed

.env

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
##################### 用户端专有配置 #####################
2+
USER_HTTP_PORT=9000 # 用户端的 HTTP 监听端口. 默认 8080
3+
USER_HTTP_DOMAIN=http://localhost:9000 # 用户端的 API 域名
4+
USER_TOKEN_SECRET_KEY=user # 用户端的 JWT token 密钥
5+
USER_TLS_CERT="" # TLS 的证书文件
6+
USER_TLS_KEY="" # TLS 的 key 文件
7+
8+
######################## 公共配置 ########################
9+
# 通用
10+
MACHINE_ID="0" # 机器 ID, 在集群中,每个ID都应该不同,用于产出不同的 ID
11+
GO_MOD="production" # 处于开发模式(development)/生产模式(production), 默认 development
12+
SIGNATURE_KEY="signature key" # 数据签名的密钥, 该配置不可泄漏
13+
14+
# 主数据库设置
15+
DB_HOST="${DB_HOST}" # 默认 localhost
16+
DB_PORT="${DB_PORT}" # 默认 "65432", postgres 官方端口 54321
17+
DB_DRIVER="${DB_DRIVER}" # 默认 "postgres"
18+
DB_NAME="${DB_NAME}" # 默认 "gotest"
19+
DB_USERNAME="${DB_USERNAME}" # 默认 "gotest"
20+
DB_PASSWORD="${DB_PASSWORD}" # 默认 "gotest"
21+
DB_SYNC=on # 在应用启动时,是否同步数据库表, 可选 on/off, 默认 off
22+
23+
# OAuth2 认证服务
24+
OAUTH_REDIRECT_URL="${OAUTH_REDIRECT_URL}" # 认证成功后,跳转到前端的 URL 地址, 携带 code 给前端拿到用户相关的 token
25+
GITHUB_KEY="${GITHUB_KEY}"
26+
GITHUB_SECRET="${GITHUB_SECRET}"
27+
GITLAB_KEY="${GITLAB_KEY}"
28+
GITLAB_SECRET="${SECRET}"
29+
GOOGLE_KEY="${GOOGLE_KEY}"
30+
GOOGLE_SECRET="${GOOGLE_SECRET}"
31+
FACEBOOK_KEY="${FACEBOOK_KEY}"
32+
FACEBOOK_SECRET="${SECRET}"
33+
TWITTER_KEY="${TWITTER_KEY}"
34+
TWITTER_SECRET="${TWITTER_SECRET}"

.gitignore

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Created by .ignore support plugin (hsz.mobi)
2+
### Go template
3+
# Binaries for programs and plugins
4+
*.exe
5+
*.exe~
6+
*.dll
7+
*.so
8+
*.dylib
9+
10+
# Test binary, built with `go test -c`
11+
*.test
12+
13+
# Output of the go coverage tool, specifically when used with LiteIDE
14+
*.out
15+
16+
# Dependency directories (remove the comment below to include it)
17+
# vendor/
18+
19+
.idea
20+
.DS_Store
21+
docker/volumes

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### web terminal for remote server
2+
3+
write in Golang

cmd/README.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### 入口说明
2+
3+
#### user
4+
5+
用户端的入口文件
6+
7+
#### admin
8+
9+
管理员端的入口文件
10+
11+
#### message_queue
12+
13+
消息队列的入口文件

cmd/user/main.go

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Copyright 2019 Axetroy. All rights reserved. MIT license.
2+
package main
3+
4+
import (
5+
app2 "github.com/axetroy/terminal/internal/app"
6+
"log"
7+
"os"
8+
9+
App "github.com/axetroy/terminal"
10+
"github.com/axetroy/terminal/internal/library/daemon"
11+
"github.com/axetroy/terminal/internal/library/util"
12+
"github.com/urfave/cli"
13+
)
14+
15+
func main() {
16+
app := cli.NewApp()
17+
app.Usage = "user server controller"
18+
app.Author = App.Author
19+
app.Email = App.Email
20+
app.Version = App.Version
21+
cli.AppHelpTemplate = App.CliTemplate
22+
23+
app.Commands = []cli.Command{
24+
{
25+
Name: "start",
26+
Usage: "start user server",
27+
Flags: []cli.Flag{
28+
cli.BoolFlag{
29+
Name: "daemon, d",
30+
Usage: "running in daemon mode",
31+
},
32+
},
33+
Action: func(c *cli.Context) error {
34+
// 判断当其是否是子进程,当父进程return之后,子进程会被系统1号进程接管
35+
return daemon.Start(app2.Serve, c.Bool("daemon"))
36+
},
37+
},
38+
{
39+
Name: "stop",
40+
Usage: "stop user server",
41+
Action: func(c *cli.Context) error {
42+
return daemon.Stop()
43+
},
44+
},
45+
{
46+
Name: "env",
47+
Usage: "print runtime environment",
48+
Action: func(c *cli.Context) error {
49+
util.PrintEnv()
50+
return nil
51+
},
52+
},
53+
}
54+
55+
if err := app.Run(os.Args); err != nil {
56+
log.Fatal(err)
57+
}
58+
}

docker/docker-compose.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
version: '3'
2+
services:
3+
# 数据库
4+
pg:
5+
image: postgres:9.6.16-alpine
6+
restart: always
7+
volumes:
8+
- "./volumes/pg:/var/lib/postgresql/data"
9+
ports:
10+
- 54321:5432
11+
environment:
12+
- POSTGRES_USER=terminal # 用户名
13+
- POSTGRES_PASSWORD=terminal # 数据库密码
14+
- POSTGRES_DB=terminal # 数据库名
15+
16+
# 缓存
17+
redis:
18+
image: redis:5.0.7-alpine
19+
restart: always
20+
ports:
21+
- 6379:6379
22+
volumes:
23+
- "./volumes/redis:/data"
24+
environment:
25+
- REDIS_PASSWORD=password
26+
command: [ "redis-server", "--requirepass", "password" ]

docker/start.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
docker-compose up -d

docker/stop.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
docker-compose down

go.mod

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module github.com/axetroy/terminal
2+
3+
go 1.13
4+
5+
require (
6+
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a
7+
github.com/axetroy/go-fs v1.0.0
8+
github.com/axetroy/mocker v1.1.0
9+
github.com/dgrijalva/jwt-go v3.2.0+incompatible
10+
github.com/fatih/color v1.7.0
11+
github.com/gin-gonic/gin v1.4.0
12+
github.com/go-redis/redis v6.15.6+incompatible
13+
github.com/gorilla/mux v1.7.3
14+
github.com/gorilla/websocket v1.4.1
15+
github.com/holdno/snowFlakeByGo v0.0.0-20180510033652-d23f8a8cadd7
16+
github.com/jinzhu/gorm v1.9.11
17+
github.com/joho/godotenv v1.3.0
18+
github.com/kr/pretty v0.1.0 // indirect
19+
github.com/lib/pq v1.2.0
20+
github.com/markbates/goth v1.59.0
21+
github.com/mattn/go-colorable v0.1.4 // indirect
22+
github.com/mitchellh/mapstructure v1.1.2
23+
github.com/stretchr/testify v1.4.0
24+
github.com/urfave/cli v1.22.2
25+
golang.org/x/crypto v0.0.0-20191119213627-4f8c1d86b1ba
26+
)

0 commit comments

Comments
 (0)