로그 저장 로직 단순화
This commit is contained in:
@ -71,41 +71,13 @@ type HoustonClient interface {
|
||||
Start()
|
||||
}
|
||||
|
||||
type bufferStack struct {
|
||||
pool [5][]byte
|
||||
cursor int32
|
||||
}
|
||||
|
||||
func (bs *bufferStack) pop() []byte {
|
||||
pos := atomic.LoadInt32(&bs.cursor)
|
||||
for !atomic.CompareAndSwapInt32(&bs.cursor, pos, pos+1) {
|
||||
pos = atomic.LoadInt32(&bs.cursor)
|
||||
}
|
||||
|
||||
defer func() {
|
||||
bs.pool[pos] = nil
|
||||
}()
|
||||
|
||||
curbuf := bs.pool[pos]
|
||||
if curbuf == nil {
|
||||
curbuf = make([]byte, 1024)
|
||||
}
|
||||
return curbuf
|
||||
}
|
||||
|
||||
func (bs *bufferStack) push(x []byte) {
|
||||
pos := atomic.AddInt32(&bs.cursor, -1)
|
||||
bs.pool[pos] = x
|
||||
}
|
||||
|
||||
type procmeta struct {
|
||||
cmd *exec.Cmd
|
||||
name string
|
||||
version string
|
||||
state protos.ProcessState
|
||||
stdin io.WriteCloser
|
||||
logUploadChan chan *shared.UploadRequest
|
||||
buffers bufferStack
|
||||
cmd *exec.Cmd
|
||||
name string
|
||||
args []string
|
||||
version string
|
||||
state protos.ProcessState
|
||||
stdin io.WriteCloser
|
||||
}
|
||||
|
||||
type houstonClient struct {
|
||||
@ -197,7 +169,7 @@ func (hc *houstonClient) makeOperationQueryRequest() *protos.OperationQueryReque
|
||||
for _, child := range hc.childProcs {
|
||||
procs = append(procs, &protos.ProcessDescription{
|
||||
Name: child.name,
|
||||
Args: child.cmd.Args,
|
||||
Args: child.args,
|
||||
Version: child.version,
|
||||
State: child.state,
|
||||
Pid: int32(child.cmd.Process.Pid),
|
||||
@ -327,7 +299,7 @@ func NewClient(standalone bool) (HoustonClient, error) {
|
||||
hc.startChildProcess(&shared.StartProcessRequest{
|
||||
Version: proc.version,
|
||||
Name: proc.name,
|
||||
Args: proc.cmd.Args,
|
||||
Args: proc.args,
|
||||
}, op)
|
||||
}
|
||||
}(proc)
|
||||
|
||||
Reference in New Issue
Block a user