Skip to content

Commit 46585ef

Browse files
committed
end
1 parent 119751d commit 46585ef

8 files changed

Lines changed: 56 additions & 7 deletions

File tree

HTTPsBAS-Procedures

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Subproject commit 7eb2512bb0dd49c69898ce3cb0fa508e0a63b747
1+
Subproject commit c2189a5e9d0d37773dacb839d1acc6c7649aa9a5

Model/AgentStatus.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func (s *AgentStatusDB) InsertRecord(data *AgentStatusRecord) error {
124124
}
125125
if count > 0 {
126126
// 중복된 항목이 있으면 업데이트
127-
return s.UpdateRecord(data)
127+
return s.UpdateRecordNoNick(data)
128128
}
129129

130130
query := fmt.Sprintf(`INSERT INTO %s (uuid, nickName, status, protocol) VALUES (?, ?, ?, ?)`, s.dbName)
@@ -211,6 +211,22 @@ func (s *AgentStatusDB) UpdateRecord(data *AgentStatusRecord) error {
211211
return nil
212212
}
213213

214+
func (s *AgentStatusDB) UpdateRecordNoNick(data *AgentStatusRecord) error {
215+
db, err := getDBPtr()
216+
if err != nil {
217+
return err
218+
}
219+
defer db.Close()
220+
221+
query := fmt.Sprintf(`UPDATE %s SET status = ? WHERE uuid = ?`, s.dbName)
222+
_, err = db.Exec(query, data.Status, data.UUID)
223+
if err != nil {
224+
return err
225+
}
226+
227+
return nil
228+
}
229+
214230
// DeleteRecord deletes a record from the AgentStatus table based on its UUID.
215231
func (s *AgentStatusDB) DeleteRecord(uuid string) error {
216232
db, err := getDBPtr()

Model/db.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ func getDBPtr() (*sql.DB, error) {
2424
return db, errors.New("open db failed")
2525
}
2626

27-
db.SetMaxOpenConns(50) // 최대 오픈 커넥션 수
28-
db.SetMaxIdleConns(50) // 최대 유휴 커넥션 수;
27+
db.SetMaxOpenConns(10) // 최대 오픈 커넥션 수
28+
db.SetMaxIdleConns(10) // 최대 유휴 커넥션 수;
2929
db.SetConnMaxLifetime(5 * time.Minute) // 연결이 닫히기 전에 열려 있는 최대 시간을 설정할 수 있습니다.
3030
// 최대 5분 까지 유지
3131

Model/nosqldb.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func getCollectionPtr() (*mongo.Database, error) {
2525

2626
clientOptions := options.Client().
2727
ApplyURI("mongodb://" + MONGOID + ":" + MONGOPW + "@" + SERVER_DOMAIN + ":" + MONGOPORT). // MongoDB URI
28-
SetMaxPoolSize(300). // 최대 풀 크기
28+
SetMaxPoolSize(20). // 최대 풀 크기
2929
SetMinPoolSize(10). // 최소 풀 크기
3030
SetMaxConnIdleTime(60 * time.Second) // 최대 유휴 시간
3131
//fmt.Println("mongodb://" + MONGOID + ":" + MONGOPW + "@uskawjdu.iptime.org:17017/")

db.db

48 KB
Binary file not shown.

go1.23.1.linux-amd64.tar.gz

-70.2 MB
Binary file not shown.

main.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,23 @@ func TCPServer() {
9393
func handleTCPConnection(conn net.Conn) {
9494
reader := bufio.NewReader(conn)
9595
reader.Discard(reader.Buffered()) // 남은 버퍼를 버림
96-
// defer conn.Close() // 함수 호출 종료 후 Close
97-
96+
defer conn.Close() // 함수 호출 종료 후 Close
97+
index := 0
9898
for {
9999
buffer := make([]byte, 1024*1024)
100100
n, err := conn.Read(buffer)
101101
if err != nil {
102102
fmt.Println("Error reading from connection:", err)
103103
break
104104
}
105+
if index > 100 {
106+
break
107+
}
105108
if n < 2 {
109+
index += 1
106110
continue
107111
}
112+
index = 0
108113

109114
defer func() {
110115
if r := recover(); r != nil {

nohup.out

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,31 @@ main.handleTCPConnection({0x124fef8, 0xc000baee90})
9595
created by main.TCPServer in goroutine 5
9696
/home/ubuntu/agentApp/HTTPsBAS-ManagingServer/main.go:88 +0x25f
9797
exit status 2
98+
TCP server listening on port 8080
99+
[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.
100+
101+
[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
102+
- using env: export GIN_MODE=release
103+
- using code: gin.SetMode(gin.ReleaseMode)
104+
105+
106+
_______ __
107+
/ ____(_) /_ ___ _____
108+
/ /_ / / __ \/ _ \/ ___/
109+
/ __/ / / /_/ / __/ /
110+
/_/ /_/_.___/\___/_/ v3.0.0-beta.3
111+
--------------------------------------------------
112+
INFO Server started on: http://127.0.0.1:8002 (bound on host 0.0.0.0 and port 8002)
113+
INFO Total handlers count: 19
114+
INFO Prefork: Disabled
115+
INFO PID: 3157198
116+
INFO Total process count: 1
117+
118+
[GIN-debug] GET /swagger/*any --> github.com/swaggo/gin-swagger.CustomWrapHandler.func1 (3 handlers)
119+
[GIN-debug] [WARNING] You trusted all proxies, this is NOT safe. We recommend you to set a value.
120+
Please check https://pkg.go.dev/github.com/gin-gonic/gin#readme-don-t-trust-all-proxies for details.
121+
[GIN-debug] Listening and serving HTTP on 0.0.0.0:8001
122+
signal: interrupt
123+
[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.
124+
125+
Error starting HTTP server: failed to listen: failed to listen: listen tcp4 :8002: bind: address already in use

0 commit comments

Comments
 (0)