2021-12-01 01:36:32 +05:30
|
|
|
// Copyright 2021 The Gitea Authors. All rights reserved.
|
2022-11-27 23:50:29 +05:30
|
|
|
// SPDX-License-Identifier: MIT
|
2021-12-01 01:36:32 +05:30
|
|
|
|
|
|
|
package process
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2022-03-31 22:31:43 +05:30
|
|
|
var (
|
|
|
|
SystemProcessType = "system"
|
|
|
|
RequestProcessType = "request"
|
|
|
|
NormalProcessType = "normal"
|
|
|
|
NoneProcessType = "none"
|
|
|
|
)
|
|
|
|
|
|
|
|
// process represents a working process inheriting from Gitea.
|
|
|
|
type process struct {
|
2021-12-01 01:36:32 +05:30
|
|
|
PID IDType // Process ID, not system one.
|
|
|
|
ParentPID IDType
|
|
|
|
Description string
|
|
|
|
Start time.Time
|
|
|
|
Cancel context.CancelFunc
|
2022-03-31 22:31:43 +05:30
|
|
|
Type string
|
2021-12-01 01:36:32 +05:30
|
|
|
}
|
|
|
|
|
2022-03-31 22:31:43 +05:30
|
|
|
// ToProcess converts a process to a externally usable Process
|
|
|
|
func (p *process) toProcess() *Process {
|
|
|
|
process := &Process{
|
|
|
|
PID: p.PID,
|
|
|
|
ParentPID: p.ParentPID,
|
|
|
|
Description: p.Description,
|
|
|
|
Start: p.Start,
|
|
|
|
Type: p.Type,
|
2021-12-01 01:36:32 +05:30
|
|
|
}
|
2022-03-31 22:31:43 +05:30
|
|
|
return process
|
2021-12-01 01:36:32 +05:30
|
|
|
}
|