From 89f3c842e83c6e73556ffbb4c80be104d53bdf4f Mon Sep 17 00:00:00 2001 From: kishiguro Date: Mon, 20 Feb 2017 00:45:44 -0800 Subject: [PATCH] Initial commit. --- README.md | 3 +++ proc.go | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++ proc_test.go | 25 +++++++++++++++++++ 3 files changed, 96 insertions(+) create mode 100644 README.md create mode 100644 proc.go create mode 100644 proc_test.go diff --git a/README.md b/README.md new file mode 100644 index 0000000..2e8e907 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# proc + +Process management library. diff --git a/proc.go b/proc.go new file mode 100644 index 0000000..b3b61c8 --- /dev/null +++ b/proc.go @@ -0,0 +1,68 @@ +// Copyright 2017 CoreSwitch +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package proc + +import ( + "sync" +) + +type Proc struct { + Name string + Vrf string + Args []string + File string +} + +type ProcList map[string]*Proc + +var ( + ProcVrfMap = map[string]*ProcList{} + ProcMutex sync.RWMutex +) + +func NewProc(name string, vrf string, args ...string) *Proc { + proc := &Proc{ + Name: name, + Vrf: vrf, + Args: []string(args), + } + return proc +} + +func ProcRegister(proc *Proc) { + ProcMutex.Lock() + defer ProcMutex.Unlock() +} + +func ProcUnregister(proc *Proc) { + ProcMutex.Lock() + defer ProcMutex.Unlock() +} + +func ProcUnregisterByCommand(name string) { + ProcMutex.Lock() + defer ProcMutex.Unlock() +} + +func ProcUnregisterByVrf() { + ProcMutex.Lock() + defer ProcMutex.Unlock() +} + +func (proc *Proc) Start() { +} + +func (proc *Proc) Stop() { +} diff --git a/proc_test.go b/proc_test.go new file mode 100644 index 0000000..16069df --- /dev/null +++ b/proc_test.go @@ -0,0 +1,25 @@ +// Copyright 2017 CoreSwitch +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package proc + +import ( + "testing" +) + +func TestProcStart(t *testing.T) { + args := []string{"-d", "-f"} + proc := NewProc("dhcp", "", args...) + ProcRegister(proc) +}