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
baa1c6d2
Commit
baa1c6d2
authored
4 years ago
by
Bo-Chun Chen
Browse files
Options
Downloads
Patches
Plain Diff
Add timeout handler
parent
2a82f31a
No related branches found
No related tags found
4 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
,
!61
Feat error handle cli
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
create_account.py
+11
-0
11 additions, 0 deletions
create_account.py
with
11 additions
and
0 deletions
create_account.py
+
11
−
0
View file @
baa1c6d2
...
@@ -3,6 +3,7 @@ import json
...
@@ -3,6 +3,7 @@ import json
import
sys
import
sys
import
rc_util
import
rc_util
import
argparse
import
argparse
import
signal
parser
=
argparse
.
ArgumentParser
()
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'
username
'
,
help
=
'
username that will be created
'
)
parser
.
add_argument
(
'
username
'
,
help
=
'
username that will be created
'
)
...
@@ -14,12 +15,18 @@ parser.add_argument('-v', '--verbose', action='store_true', help='verbose output
...
@@ -14,12 +15,18 @@ parser.add_argument('-v', '--verbose', action='store_true', help='verbose output
parser
.
add_argument
(
'
-n
'
,
'
--dry-run
'
,
action
=
'
store_true
'
,
help
=
'
enable dry run mode
'
)
parser
.
add_argument
(
'
-n
'
,
'
--dry-run
'
,
action
=
'
store_true
'
,
help
=
'
enable dry run mode
'
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
timeout
=
60
if
args
.
email
==
''
:
if
args
.
email
==
''
:
args
.
email
=
args
.
username
args
.
email
=
args
.
username
if
'
@
'
not
in
args
.
email
:
if
'
@
'
not
in
args
.
email
:
args
.
email
=
args
.
username
+
'
@
'
+
args
.
domain
args
.
email
=
args
.
username
+
'
@
'
+
args
.
domain
def
timeout_handler
(
signum
,
frame
):
print
(
"
Process timeout, there
'
s might some issue with agents
"
)
rc_util
.
rc_rmq
.
stop_consume
()
def
callback
(
channel
,
method
,
properties
,
body
):
def
callback
(
channel
,
method
,
properties
,
body
):
msg
=
json
.
loads
(
body
)
msg
=
json
.
loads
(
body
)
username
=
msg
[
'
username
'
]
username
=
msg
[
'
username
'
]
...
@@ -39,5 +46,9 @@ def callback(channel, method, properties, body):
...
@@ -39,5 +46,9 @@ def callback(channel, method, properties, body):
rc_util
.
add_account
(
args
.
username
,
email
=
args
.
email
,
full
=
args
.
full_name
,
reason
=
args
.
reason
)
rc_util
.
add_account
(
args
.
username
,
email
=
args
.
email
,
full
=
args
.
full_name
,
reason
=
args
.
reason
)
print
(
f
'
Account for
{
args
.
username
}
requested.
'
)
print
(
f
'
Account for
{
args
.
username
}
requested.
'
)
# Set initial timeout timer
signal
.
signal
(
signal
.
SIGALRM
,
timeout_handler
)
signal
.
setitimer
(
signal
.
ITIMER_REAL
,
timeout
)
print
(
'
Waiting for completion...
'
)
print
(
'
Waiting for completion...
'
)
rc_util
.
consume
(
args
.
username
,
routing_key
=
f
'
complete.
{
args
.
username
}
'
,
callback
=
callback
)
rc_util
.
consume
(
args
.
username
,
routing_key
=
f
'
complete.
{
args
.
username
}
'
,
callback
=
callback
)
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