Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
rabbitmq_agents
Manage
Activity
Members
Labels
Plan
Issues
14
Issue boards
Milestones
Wiki
Code
Merge requests
8
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
rc
rabbitmq_agents
Commits
e6537d38
Commit
e6537d38
authored
4 years ago
by
Bo-Chun Chen
Browse files
Options
Downloads
Patches
Plain Diff
Add database settings
parent
38251670
No related branches found
Branches containing commit
No related tags found
5 merge requests
!147
Merge previous default branch feat-cod-rmq into main
,
!85
kill nginx process running under user from login node
,
!78
Feat cod rmq
,
!62
Feat notify user errmsg
,
!63
Feat db handle
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
task_manager.py
+27
-0
27 additions, 0 deletions
task_manager.py
with
27 additions
and
0 deletions
task_manager.py
+
27
−
0
View file @
e6537d38
...
...
@@ -3,6 +3,7 @@ import sys
import
copy
import
json
import
signal
import
dataset
import
rc_util
import
smtplib
from
rc_rmq
import
RCRMQ
...
...
@@ -15,6 +16,9 @@ timeout = 30
args
=
rc_util
.
get_args
()
logger
=
rc_util
.
get_logger
(
args
)
db
=
dataset
.
connect
(
f
'
sqlite:///.agent_db/user_reg.db
'
)
table
=
db
[
'
users
'
]
record
=
{
'
uid
'
:
-
1
,
'
gid
'
:
-
1
,
...
...
@@ -77,6 +81,29 @@ def notify_admin(username, user_record):
logger
.
debug
(
f
'
User report sent to:
{
mail_cfg
.
Admin_email
}
'
)
def
insert_db
(
username
,
msg
):
# Search username in db
record
=
table
.
find_one
(
username
=
username
)
if
not
record
:
# SQL insert
table
.
insert
({
'
username
'
:
username
,
'
uid
'
:
msg
.
get
(
'
uid
'
,
-
1
),
'
gid
'
:
msg
.
get
(
'
gid
'
,
-
1
),
'
email
'
:
msg
.
get
(
'
email
'
,
''
),
'
reason
'
:
msg
.
get
(
'
reason
'
,
''
),
'
fullname
'
:
msg
.
get
(
'
fullname
'
,
''
),
'
sent
'
:
None
,
'
last_update
'
:
datetime
.
now
()
})
def
update_db
(
username
,
data
):
obj
=
{
'
username
'
:
username
,
**
data
}
table
.
update
(
obj
,
[
'
username
'
])
def
task_manager
(
ch
,
method
,
properties
,
body
):
msg
=
json
.
loads
(
body
)
username
=
method
.
routing_key
.
split
(
'
.
'
)[
1
]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment