aboutsummaryrefslogtreecommitdiffstats
path: root/modules/process
Commit message (Collapse)AuthorAgeFilesLines
* Add Goroutine stack inspector to admin/monitor (#19207)zeripath2022-03-316-207/+551
| | | | | | | | | | | | | | | | | | | Continues on from #19202. Following the addition of pprof labels we can now more easily understand the relationship between a goroutine and the requests that spawn them. This PR takes advantage of the labels and adds a few others, then provides a mechanism for the monitoring page to query the pprof goroutine profile. The binary profile that results from this profile is immediately piped in to the google library for parsing this and then stack traces are formed for the goroutines. If the goroutine is within a context or has been created from a goroutine within a process context it will acquire the process description labels for that process. The goroutines are mapped with there associate pids and any that do not have an associated pid are placed in a group at the bottom as unbound. In this way we should be able to more easily examine goroutines that have been stuck. A manager command `gitea manager processes` is also provided that can export the processes (with or without stacktraces) to the command line. Signed-off-by: Andrew Thornton <art27@cantab.net>
* Refactor `git.Command.Run*`, introduce `RunWithContextString` and ↵wxiaoguang2022-03-311-1/+5
| | | | | | | | | | | | | | | | | | `RunWithContextBytes` (#19266) This follows * https://github.com/go-gitea/gitea/issues/18553 Introduce `RunWithContextString` and `RunWithContextBytes` to help the refactoring. Add related unit tests. They keep the same behavior to save stderr into err.Error() as `RunInXxx` before. Remove `RunInDirTimeoutPipeline` `RunInDirTimeoutFullPipeline` `RunInDirTimeout` `RunInDirTimeoutEnv` `RunInDirPipeline` `RunInDirFullPipeline` `RunTimeout`, `RunInDirTimeoutEnvPipeline`, `RunInDirTimeoutEnvFullPipeline`, `RunInDirTimeoutEnvFullPipelineFunc`. Then remaining `RunInDir` `RunInDirBytes` `RunInDirWithEnv` can be easily refactored in next PR with a simple search & replace: * before: `stdout, err := RunInDir(path)` * next: `stdout, _, err := RunWithContextString(&git.RunContext{Dir:path})` Other changes: 1. When `timeout <= 0`, use default. Because `timeout==0` is meaningless and could cause bugs. And now many functions becomes more simple, eg: `GitGcRepos` 9 lines to 1 line. `Fsck` 6 lines to 1 line. 2. Only set defaultCommandExecutionTimeout when the option `setting.Git.Timeout.Default > 0`
* Add pprof labels in processes and for lifecycles (#19202)zeripath2022-03-251-8/+11
| | | | | | Use pprof labelling to help identify goroutines with stacks. Signed-off-by: Andrew Thornton <art27@cantab.net>
* format with gofumpt (#18184)65432022-01-202-3/+0
| | | | | | | | | | | * gofumpt -w -l . * gofumpt -w -l -extra . * Add linter * manual fix * change make fmt
* Propagate context and ensure git commands run in request context (#17868)zeripath2022-01-191-8/+8
| | | | | | | | | This PR continues the work in #17125 by progressively ensuring that git commands run within the request context. This now means that the if there is a git repo already open in the context it will be used instead of reopening it. Signed-off-by: Andrew Thornton <art27@cantab.net>
* Fix various typos (#18219)luzpaz2022-01-101-1/+1
| | | | | Found via `codespell -q 3 -S ./options/locale,./vendor -L ba,pullrequest,pullrequests,readby,te,unknwon` Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Make Requests Processes and create process hierarchy. Associate ↵zeripath2021-11-304-63/+319
| | | | | | | | | OpenRepository with context. (#17125) This PR registers requests with the process manager and manages hierarchy within the processes. Git repos are then associated with a context, (usually the request's context) - with sub commands using this context as their base context. Signed-off-by: Andrew Thornton <art27@cantab.net>
* Code Formats, Nits & Unused Func/Var deletions (#15286)65432021-04-091-5/+2
| | | | | | | | | | | | | | | * _ to unused func options * rm useless brakets * rm trifial non used models functions * rm dead code * rm dead global vars * fix routers/api/v1/repo/issue.go * dont overload import module
* Reduce data races (#14549)65432021-02-032-2/+12
| | | | | | | | | | | * Add race conditions into test * Fix Race in GetManager() * DataAsync() use error chan * just log no chan * finish
* Only write to global gitconfig if necessary (#11876)zeripath2020-06-131-1/+27
| | | | | | | | | | | | | * Only write to global gitconfig if necessary Fix #11855 Signed-off-by: Andrew Thornton <art27@cantab.net> * placate lint Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Add gitea-vet (#10948)John Olheiser2020-04-051-0/+4
| | | | | | | | | | | | | | | | | * Add copyright Signed-off-by: jolheiser <john.olheiser@gmail.com> * Add gitea-vet and fix non-compliance Signed-off-by: jolheiser <john.olheiser@gmail.com> * Combine tools.go into build.go and clean up Signed-off-by: jolheiser <john.olheiser@gmail.com> * Remove extra GO111MODULE=on Signed-off-by: jolheiser <john.olheiser@gmail.com>
* Graceful: Cancel Process on monitor pages & HammerTime (#9213)zeripath2019-11-302-34/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * Graceful: Create callbacks to with contexts * Graceful: Say when Gitea is completely finished * Graceful: Git and Process within HammerTime Force all git commands to terminate at HammerTime Force all process commands to terminate at HammerTime Move almost all git processes to run as git Commands * Graceful: Always Hammer after Shutdown * ProcessManager: Add cancel functionality * Fix tests * Make sure that process.Manager.Kill() cancels * Make threadsafe access to Processes and remove own unused Kill * Remove cmd from the process manager as it is no longer used * the default context is the correct context * get rid of double till
* Restore functionality for early gits (#7775)zeripath2019-10-121-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | * Change tests to make it possible to run TestGit with 1.7.2 * Make merge run on 1.7.2 * Fix tracking and staging branch name problem * Ensure that git 1.7.2 works on tests * ensure that there is no chance for conflicts * Fix-up missing merge issues * Final rm * Ensure LFS filters run on the tests * Do not sign commits from temp repo * Restore tracking fetch change * Apply suggestions from code review * Update modules/repofiles/temp_repo.go
* Fix run command race (#1470)Mura Li2017-11-132-22/+33
| | | | | | | | | | * Use exec.CommandContext to simplfy timeout handling And fixing the data races which can be identified by the added tests when -race enabled. * Use sleep commmand instead of reading from stdin * Make the error handling go-esque
* Refactor process package and introduce ProcessManager{} with tests (#75)Matthias Loibl2017-01-172-72/+120
| | | | | | | | | | * Add a process.Manager singleton with process.GetManager() * Use process.GetManager everywhere * Fix godoc comments for process module * Increment process counter id after locking the mutex
* modules/process: add ExecDirEnv (next to ExecDir)Mura Li2016-11-271-2/+8
| | | | | | | Add a sibling to ExecDir which is capable of specifying environment variables, so that we can invoke `git` with GIT_INDEX_FILE, GIT_DIR, etc.. For #258
* Lint and document manager apiSandro Santilli2016-11-241-8/+17
|
* Update import paths from github.com/go-gitea to code.gitea.io (#135)Sandro Santilli2016-11-101-1/+1
| | | | | | | - Update import paths from github.com/go-gitea to code.gitea.io - Fix import path for travis See https://docs.travis-ci.com/user/languages/go#Go-Import-Path
* Change import reference to match gitea instead of gogs (#37)Rémy Boulanouar2016-11-031-1/+1
|
* introduce git-shellUnknwon2015-11-261-1/+2
|
* New UI merge in progressUnknwon2014-07-261-1/+1
|
* Able to set timeout for process monitorUnknown2014-07-061-6/+43
|
* Basic process managerUnknown2014-06-191-0/+89