-
Notifications
You must be signed in to change notification settings - Fork 0
FEATURE: Add 'memcached start|stop|list' command to manage server znode #17
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
Conversation
namsic
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ผ๋ถ ๋ฆฌ๋ทฐ
์กฐํ ๋ช
๋ น์ ์ถ๋ ฅ ๊ฒฐ๊ณผ ์์๋ฅผ PR ์ค๋ช
์ ์ถ๊ฐํด์ค ์ ์๋์?
cmd/memcached/list.go
Outdated
| if len(serviceCodeServers) == 0 { | ||
| fmt.Printf("No servers found for service code '%s'.\n", serviceCode) | ||
| os.Exit(1) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
acl list์ ๋ง์ฐฌ๊ฐ์ง๋ก
์๋ Total ๋ณด์ฌ์ฃผ๊ณ ์์ผ๋ฏ๋ก ๋ณ๋๋ก ์ฒ๋ฆฌํ์ง ์์๋ ๋ ๊ฒ ๊ฐ์ต๋๋ค.
cmd/memcached/listall.go
Outdated
| serviceCodes, _, err := zkConn.Children(path.Join(internal.ArcusCacheListPath)) | ||
| if err != nil { | ||
| fmt.Fprintln(os.Stderr, err) | ||
| os.Exit(1) | ||
| } | ||
|
|
||
| var statuses []serviceStatus | ||
| for _, sc := range serviceCodes { | ||
| serviceCodeServers, _ := getServiceCodeServers(zkConn, sc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cache_server_mapping์ ์๋น์ค์ฝ๋ ๋จ์๋ก ๋๋ ํ ๋ฆฌ๊ฐ ๋ถ๋ฆฌ๋์ด ์์ง ์์ผ๋ฏ๋ก,
์ด๋ค ์๋น์ค์ฝ๋๋ฅผ ์กฐํํ๋๋ผ๋ /arcus/cache_server_mapping์ ๋ชจ๋ children์ ํ์ํ๊ฒ ๋ฉ๋๋ค.
ํ์ฌ ๊ตฌํ์์ ์๋น์ค์ฝ๋๊ฐ ๋ง์ผ๋ฉด ๊ฐ์ znode๋ฅผ ์๋น์ค์ฝ๋ ์๋งํผ ์ค๋ณต ์กฐํํ๊ณ , ZK์ ๋ง์ ์ฐ์ฐ์ด ๋ณด๋ด์ง๊ฒ ๋ฉ๋๋ค.
cache_server_mapping์ ํ์ํ๋ฉด์ map[string][]string ํํ์ ์๋น์ค์ฝ๋ + ๋
ธ๋ ๋ชฉ๋ก์ ๋ง๋ค์ด ๋๋ฉด,
์ฌ๋ฌ ์๋น์ค์ฝ๋์ ๋ํ ์ ๋ณด ์กฐํ ์ ์ฌ์ฌ์ฉํ ์ ์์ต๋๋ค.
| command := fmt.Sprintf(memcachedStartCommandTemplate, | ||
| memcachedPath, memcachedPath, memcachedPath, memcachedPath, memcachedPath, | ||
| port, string(globalConfig), os.Getenv("ZK_ADDR")) | ||
|
|
||
| ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) | ||
| defer cancel() | ||
| errChan := make(chan error, 1) | ||
| go func() { | ||
| errChan <- session.Run(command) | ||
| }() | ||
| select { | ||
| case err := <-errChan: | ||
| if err != nil { | ||
| fmt.Fprintln(os.Stderr, err) | ||
| os.Exit(1) | ||
| } | ||
| case <-ctx.Done(): | ||
| continue | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nohup ๋์ timeout ์ฌ์ฉํ๊ธฐ๋ก ํ์๋์?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๋ ๋ฐฉ์ ๋ชจ๋ ๋ฌด๋ฐฉํ๋ค๊ณ ํ์ ์, ๊ธฐ์กด ๋ ๊ฑฐ์์ฝ๋ ๊ตฌํ์ ๊ทธ๋๋ก ์ ์งํ๊ณ ์ timeout์ผ๋ก ๊ตฌํํ์ต๋๋ค.
|
|
cmd/memcached/listall.go
Outdated
| status := "OK" | ||
| if len(serviceCodeServers) > 0 { | ||
| if onlineCnt == 0 { | ||
| status = "DOWN" | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
online / offline ์ ๋ณด์ ์ค๋ณต์ด๋ฏ๋ก, ๋ณ๋๋ก ์ ๊ณตํ ํ์ ์์ด ๋ณด์ ๋๋ค.
์๋ฒ๊ฐ ๋ชจ๋ ๋จ์ด์ง ๊ฒฝ์ฐ์๋ง DOWN์ด๊ณ ๊ทธ ์ธ์๋ OK ์ฒ๋ฆฌํ๊ณ ์๋๋ฐ,
์ด๋ฌํ ๊ตฌ๋ถ ๊ธฐ์ค๋ ๋ณ๋ ์ค๋ช
์์ด๋ ์ง๊ด์ ์ผ๋ก ํ์
ํ๊ธฐ ์ด๋ ต์ต๋๋ค.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
status๋ถ๋ถ์ ์ ๊ฑฐํ๊ฒ ์ต๋๋ค. listall๋ช
๋ น์ ์๋์ ๊ฐ์ด ์๋ตํ๋๋ก ์์ ํ์ต๋๋ค.
SERVICE CODE TOTAL ONLINE OFFLINE
------------------------------------------------------------
test 2 0 2
5f3b94f to
0585acb
Compare
memcached ์ถ๋ ฅ๊ธฐ์กด์ ๋จ์ผ serviceCode์ memcached ์๋ฒ๋ฅผ ์ถ๋ ฅํ๋
์ถ๋ ฅ๊ฒฐ๊ณผ์ ์์๋ ์๋์ ๊ฐ์ต๋๋ค. ๊ธฐ๋ณธ์ ์ผ๋ก ์ ์ฒด ๊ฒฐ๊ณผ์ ๊ดํด์ ์ถ๋ ฅํด์ฃผ๊ณ , serviceCode ๋ช ๋ น ์ธ์๊ฐ ์๋ค๋ฉด ํด๋น serviceCode์ ๋ํ ๊ฒฐ๊ณผ๋ฅผ ์ถ๊ฐ๋ก ์ถ๋ ฅํด์ค๋๋ค.
|
0585acb to
9f23d9b
Compare
namsic
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ฐ์ ์ด๋๋ก ๋ฐ์ํ๊ณ , ๋์ค์ ์ผ๋ถ ๊ตฌํ ๋ฆฌํฉํ ๋ง ํด๋๊ฒ ์ต๋๋ค.
๐ Related Issue
โจ๏ธ What I did
์ด์ arcus.sh์
memcached start | stop | list๊ธฐ๋ฅ์ arcus-cli์์๋ ๋์ํ๋๋ก ํฉ๋๋ค.memcached start <serviceCode> [ip:port..]/arcus/cache_list/<serviceCode>znode์ ์ ์ฅ๋, ์ ์ญ ์ต์ ์ผ๋ก ์ํํฉ๋๋ค.memcached stop <serviceCode> [ip:port...]-P์ต์ ์ ํตํด pid๋ฅผ ๋ฏธ๋ฆฌ ์ ์ฅํ๊ณ , ํด๋น pid๋ฅผ ํตํด ํ๋ก์ธ์ค๋ฅผ ์ข ๋ฃํฉ๋๋ค.memcached list <serviceCode>memcached listall