Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
fa34f7cb
authored
Jul 02, 2014
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: measure boot time
parent
f06fe9b9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
0 deletions
+23
-0
circle/vm/tasks/local_agent_tasks.py
+23
-0
No files found.
circle/vm/tasks/local_agent_tasks.py
View file @
fa34f7cb
...
@@ -24,7 +24,9 @@ from base64 import encodestring
...
@@ -24,7 +24,9 @@ from base64 import encodestring
from
StringIO
import
StringIO
from
StringIO
import
StringIO
from
tarfile
import
TarFile
,
TarInfo
from
tarfile
import
TarFile
,
TarInfo
from
django.conf
import
settings
from
django.conf
import
settings
from
django.utils
import
timezone
from
celery.result
import
TimeoutError
from
celery.result
import
TimeoutError
from
monitor.client
import
Client
def
send_init_commands
(
instance
,
act
,
vm
):
def
send_init_commands
(
instance
,
act
,
vm
):
...
@@ -86,12 +88,33 @@ def agent_started(vm, version=None):
...
@@ -86,12 +88,33 @@ def agent_started(vm, version=None):
pass
pass
if
not
initialized
:
if
not
initialized
:
measure_boot_time
(
instance
)
send_init_commands
(
instance
,
act
,
vm
)
send_init_commands
(
instance
,
act
,
vm
)
with
act
.
sub_activity
(
'start_access_server'
):
with
act
.
sub_activity
(
'start_access_server'
):
start_access_server
.
apply_async
(
queue
=
queue
,
args
=
(
vm
,
))
start_access_server
.
apply_async
(
queue
=
queue
,
args
=
(
vm
,
))
def
measure_boot_time
(
instance
):
if
not
instance
.
template
:
return
from
vm.models
import
InstanceActivity
deploy_time
=
InstanceActivity
.
objects
.
filter
(
instance
=
instance
,
activity_code
=
"vm.Instance.deploy"
)
.
latest
(
"finished"
)
.
finished
total_boot_time
=
(
timezone
.
now
()
-
deploy_time
)
.
total_seconds
()
Client
()
.
send
([
"template.
%(pk)
d.boot_time
%(val)
f
%(time)
s"
%
{
'pk'
:
instance
.
template
.
pk
,
'val'
:
total_boot_time
,
'time'
:
time
.
time
(),
}
])
@celery.task
@celery.task
def
agent_stopped
(
vm
):
def
agent_stopped
(
vm
):
from
vm.models
import
Instance
,
InstanceActivity
from
vm.models
import
Instance
,
InstanceActivity
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment