Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: migrate website from jupiter-website #523

Merged
merged 13 commits into from
Oct 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/deploy-website.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# 构建vuepress,并提交到pages分支
name: deploy

on:
push:
paths:
- "website/**"
branches:
- "master"

jobs:
build:
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

# 首先生成拉取node文件
- name: Node install
uses: actions/setup-node@v1
with:
node-version: "16.x"

# 缓存 node_modules
- name: Cache dependencies
uses: actions/cache@v2
id: npm-cache
with:
path: |
**/node_modules
key: ${{ runner.os }}-npm-cache
restore-keys: |
${{ runner.os }}-npm-

# 如果缓存没有命中,安装依赖
- name: Install dependencies
if: steps.npm-cache.outputs.cache-hit != 'true'
run: cd website && npm install vuepress

# 运行构建脚本
- name: Build VuePress site
run: cd website && npm run docs:build

# 提交
- name: Deploy 🚀
uses: JamesIves/[email protected]
with:
branch: pages
folder: ./website/docs/.vuepress/dist
9 changes: 8 additions & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ name: Go

on:
push:
paths-ignore:
- "website/**"
branches:
- "master"
pull_request:
paths-ignore:
- "website/**"
branches:
- "master"

Expand Down Expand Up @@ -42,7 +46,10 @@ jobs:
go env
go get -v -t -d ./...

- uses: actions/[email protected]
- name: golangci-lint
uses: golangci/[email protected]
with:
version: v1.50.1

- name: Build
run: go build -v .
Expand Down
56 changes: 0 additions & 56 deletions .github/workflows/lint-go.yml

This file was deleted.

1 change: 1 addition & 0 deletions pkg/client/grpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ func getDialOptions(config *Config) []grpc.DialOption {
dialOptions = append(dialOptions,
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithResolvers(resolver.NewEtcdBuilder("etcd", config.RegistryConfig)),
grpc.WithDisableServiceConfig(),
)

svcCfg := fmt.Sprintf(`{"loadBalancingPolicy":"%s"}`, config.BalancerName)
Expand Down
12 changes: 5 additions & 7 deletions pkg/core/application/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ import (
"github.com/douyu/jupiter/pkg/core/ecode"
"github.com/douyu/jupiter/pkg/core/executor"
"github.com/douyu/jupiter/pkg/core/hooks"
"github.com/douyu/jupiter/pkg/core/rocketmq"
"github.com/douyu/jupiter/pkg/core/signals"
"github.com/douyu/jupiter/pkg/core/xgrpclog"
"github.com/douyu/jupiter/pkg/flag"
"github.com/douyu/jupiter/pkg/registry"
"github.com/douyu/jupiter/pkg/server"
Expand Down Expand Up @@ -111,14 +109,14 @@ func (app *Application) initialize() {

_ = app.parseFlags()
_ = app.printBanner()
app.initLogger()
// app.initLogger()
})
}

func (app *Application) initLogger() {
xgrpclog.SetLogger(xlog.Jupiter())
rocketmq.SetLogger(xlog.Jupiter())
}
// func (app *Application) initLogger() {
// xgrpclog.SetLogger(xlog.Jupiter())
// rocketmq.SetLogger(xlog.Jupiter())
// }

// // start up application
// // By default the startup composition is:
Expand Down
8 changes: 8 additions & 0 deletions pkg/core/rocketmq/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ package rocketmq
import (
"github.com/apache/rocketmq-client-go/v2/rlog"
"github.com/douyu/jupiter/pkg/core/ecode"
"github.com/douyu/jupiter/pkg/core/hooks"
"github.com/douyu/jupiter/pkg/xlog"
"go.uber.org/zap"
)

Expand All @@ -28,6 +30,12 @@ const (
defaultCallerSkip = 2
)

func init() {
hooks.Register(hooks.Stage_AfterLoadConfig, func() {
SetLogger(xlog.Jupiter())
})
}

func SetLogger(logger *zap.Logger) {
rlog.SetLogLevel("debug")
rlog.SetLogger(&mqLogger{
Expand Down
7 changes: 7 additions & 0 deletions pkg/core/xgrpclog/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"

"github.com/douyu/jupiter/pkg/core/ecode"
"github.com/douyu/jupiter/pkg/core/hooks"
"github.com/douyu/jupiter/pkg/xlog"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
Expand All @@ -29,6 +30,12 @@ var (
}
)

func init() {
hooks.Register(hooks.Stage_AfterLoadConfig, func() {
SetLogger(xlog.Jupiter())
})
}

// SetLogger sets loggerWrapper to grpclog
func SetLogger(logger *xlog.Logger) {
logger = logger.Named(ecode.ModClientGrpc).WithOptions(zap.AddCallerSkip(defaultCallerSkip))
Expand Down
51 changes: 25 additions & 26 deletions pkg/xlog/rotate/lumberjack_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
// Using the same rotate configuration from multiple processes on the same
// machine will result in improper behavior.

//go:build darwin
// +build darwin

package rotate
Expand Down Expand Up @@ -163,29 +164,29 @@ var (
megabyte = 1024 * 1024
)

func (l *Logger) write(p []byte) (n int, err error) {
l.mu.Lock()
defer l.mu.Unlock()
select {
case <-l.reopen:
if err := l.rotate(); err != nil {
panic(err)
}
// n, err = l.file.Write(p)
// l.size += int64(n)
n = len(p)
for len(p) > 0 {
buf := _asyncBufferPool.Get().([]byte)
num := copy(buf, p)
l.queue <- buf[:num]
p = p[num:]
}

default:
l.queue <- append(_asyncBufferPool.Get().([]byte)[0:], p...)[:len(p)]
}
return n, err
}
// func (l *Logger) write(p []byte) (n int, err error) {
// l.mu.Lock()
// defer l.mu.Unlock()
// select {
// case <-l.reopen:
// if err := l.rotate(); err != nil {
// panic(err)
// }
// // n, err = l.file.Write(p)
// // l.size += int64(n)
// n = len(p)
// for len(p) > 0 {
// buf := _asyncBufferPool.Get().([]byte)
// num := copy(buf, p)
// l.queue <- buf[:num]
// p = p[num:]
// }

// default:
// l.queue <- append(_asyncBufferPool.Get().([]byte)[0:], p...)[:len(p)]
// }
// return n, err
// }

// buffer pool for asynchronous writer
var _asyncBufferPool = sync.Pool{
Expand Down Expand Up @@ -424,9 +425,7 @@ func (l *Logger) millRunOnce() error {
// Only count the uncompressed log file or the
// compressed log file, not both.
fn := f.Name()
if strings.HasSuffix(fn, compressSuffix) {
fn = fn[:len(fn)-len(compressSuffix)]
}
fn = strings.TrimSuffix(fn, compressSuffix)
preserved[fn] = true

if len(preserved) > l.MaxBackups {
Expand Down
4 changes: 1 addition & 3 deletions pkg/xlog/rotate/lumberjack_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,7 @@ func (l *Logger) millRunOnce() error {
// Only count the uncompressed log file or the
// compressed log file, not both.
fn := f.Name()
if strings.HasSuffix(fn, compressSuffix) {
fn = fn[:len(fn)-len(compressSuffix)]
}
fn = strings.TrimSuffix(fn, compressSuffix)
preserved[fn] = true

if len(preserved) > l.MaxBackups {
Expand Down
8 changes: 8 additions & 0 deletions website/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules
.idea
package-lock.json
yarn.lock
.vuepress/dist
docs/.vuepress/dist/*
jupiter-website.tar.gz
yarn.lock
7 changes: 7 additions & 0 deletions website/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Jupiter
Jupiter的官方文档,介绍了Jupiter框架、Juno微服务管理系统,帮助用户更好的使用Jupiter。

# 构建方式
* 1.安装vuepress,``npm install vuepress``
* 2.本地执行,``npm run docs:dev``
* 3.访问``http://127.0.0.1:8080/``
Loading