Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gitlab-runner
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
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
Lars Seipel
gitlab-runner
Commits
411b9330
"controller/controller.go" did not exist on "44d01e0ba5f7ac57c071334bf6c802b20e0cbc5e"
Commit
411b9330
authored
9 years ago
by
Kamil Trzcinski
Browse files
Options
Downloads
Patches
Plain Diff
Add CPU profile option
parent
46c91b57
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
helpers/cli/cpuprofile.go
+45
-0
45 additions, 0 deletions
helpers/cli/cpuprofile.go
main.go
+1
-0
1 addition, 0 deletions
main.go
with
46 additions
and
0 deletions
helpers/cli/cpuprofile.go
0 → 100644
+
45
−
0
View file @
411b9330
package
cli_helpers
import
(
"os"
"runtime/pprof"
"github.com/codegangsta/cli"
)
func
SetupCpuProfile
(
app
*
cli
.
App
)
{
app
.
Flags
=
append
(
app
.
Flags
,
cli
.
StringFlag
{
Name
:
"cpuprofile"
,
Usage
:
"write cpu profile to file"
,
EnvVar
:
"CPU_PROFILE"
,
})
appBefore
:=
app
.
Before
appAfter
:=
app
.
After
app
.
Before
=
func
(
c
*
cli
.
Context
)
error
{
if
cpuProfile
:=
c
.
String
(
"cpuprofile"
);
cpuProfile
!=
""
{
f
,
err
:=
os
.
Create
(
cpuProfile
)
if
err
!=
nil
{
return
err
}
pprof
.
StartCPUProfile
(
f
)
}
if
appBefore
!=
nil
{
return
appBefore
(
c
)
}
else
{
return
nil
}
}
app
.
After
=
func
(
c
*
cli
.
Context
)
error
{
pprof
.
StopCPUProfile
()
if
appAfter
!=
nil
{
return
appAfter
(
c
)
}
else
{
return
nil
}
}
}
This diff is collapsed.
Click to expand it.
main.go
+
1
−
0
View file @
411b9330
...
@@ -60,6 +60,7 @@ func main() {
...
@@ -60,6 +60,7 @@ func main() {
},
},
}
}
cli_helpers
.
SetupLogLevelOptions
(
app
)
cli_helpers
.
SetupLogLevelOptions
(
app
)
cli_helpers
.
SetupCpuProfile
(
app
)
app
.
Commands
=
common
.
GetCommands
()
app
.
Commands
=
common
.
GetCommands
()
app
.
CommandNotFound
=
func
(
context
*
cli
.
Context
,
command
string
)
{
app
.
CommandNotFound
=
func
(
context
*
cli
.
Context
,
command
string
)
{
logrus
.
Fatalln
(
"Command"
,
command
,
"not found."
)
logrus
.
Fatalln
(
"Command"
,
command
,
"not found."
)
...
...
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