mirror of
https://github.com/coreswitch/process.git
synced 2025-10-05 16:07:02 +08:00
Update.
This commit is contained in:
42
process.go
42
process.go
@@ -12,28 +12,28 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package proc
|
package process
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Proc struct {
|
type Process struct {
|
||||||
Name string
|
Name string
|
||||||
Vrf string
|
Vrf string
|
||||||
Args []string
|
Args []string
|
||||||
File string
|
File string
|
||||||
}
|
}
|
||||||
|
|
||||||
type ProcList map[string]*Proc
|
type ProcessList map[string]*Process
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ProcVrfMap = map[string]*ProcList{}
|
ProcessVrfMap = map[string]*ProcessList{}
|
||||||
ProcMutex sync.RWMutex
|
ProcessMutex sync.RWMutex
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewProc(name string, vrf string, args ...string) *Proc {
|
func NewProcess(name string, vrf string, args ...string) *Process {
|
||||||
proc := &Proc{
|
proc := &Process{
|
||||||
Name: name,
|
Name: name,
|
||||||
Vrf: vrf,
|
Vrf: vrf,
|
||||||
Args: []string(args),
|
Args: []string(args),
|
||||||
@@ -41,28 +41,28 @@ func NewProc(name string, vrf string, args ...string) *Proc {
|
|||||||
return proc
|
return proc
|
||||||
}
|
}
|
||||||
|
|
||||||
func ProcRegister(proc *Proc) {
|
func ProcessRegister(proc *Process) {
|
||||||
ProcMutex.Lock()
|
ProcessMutex.Lock()
|
||||||
defer ProcMutex.Unlock()
|
defer ProcessMutex.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func ProcUnregister(proc *Proc) {
|
func ProcessUnregister(proc *Process) {
|
||||||
ProcMutex.Lock()
|
ProcessMutex.Lock()
|
||||||
defer ProcMutex.Unlock()
|
defer ProcessMutex.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func ProcUnregisterByCommand(name string) {
|
func ProcessUnregisterByCommand(name string) {
|
||||||
ProcMutex.Lock()
|
ProcessMutex.Lock()
|
||||||
defer ProcMutex.Unlock()
|
defer ProcessMutex.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func ProcUnregisterByVrf() {
|
func ProcessUnregisterByVrf() {
|
||||||
ProcMutex.Lock()
|
ProcessMutex.Lock()
|
||||||
defer ProcMutex.Unlock()
|
defer ProcessMutex.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (proc *Proc) Start() {
|
func (proc *Process) Start() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (proc *Proc) Stop() {
|
func (proc *Process) Stop() {
|
||||||
}
|
}
|
||||||
|
@@ -12,14 +12,14 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package proc
|
package process
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestProcStart(t *testing.T) {
|
func TestProcessStart(t *testing.T) {
|
||||||
args := []string{"-d", "-f"}
|
args := []string{"-d", "-f"}
|
||||||
proc := NewProc("dhcp", "", args...)
|
proc := NewProcess("dhcp", "", args...)
|
||||||
ProcRegister(proc)
|
ProcessRegister(proc)
|
||||||
}
|
}
|
Reference in New Issue
Block a user