55 "fmt"
66 "io"
77 "os/exec"
8+ "strings"
89 "sync"
910 "time"
1011
@@ -15,8 +16,8 @@ import (
1516 processList "github.com/codemodify/SystemKit/Processes/List"
1617)
1718
18- // WindowsProcessMonitor - Represents Windows service
19- type WindowsProcessMonitor struct {
19+ // TheProcessMonitor - Represents Windows service
20+ type TheProcessMonitor struct {
2021 procs map [string ]Process
2122 procsInfo map [string ]* processInfo
2223 procsSync sync.RWMutex
@@ -31,15 +32,15 @@ type processInfo struct {
3132
3233// New -
3334func New () ProcessMonitor {
34- return & WindowsProcessMonitor {
35+ return & TheProcessMonitor {
3536 procs : map [string ]Process {},
3637 procsInfo : map [string ]* processInfo {},
3738 procsSync : sync.RWMutex {},
3839 }
3940}
4041
4142// Spawn -
42- func (thisRef * WindowsProcessMonitor ) Spawn (id string , process Process ) error {
43+ func (thisRef * TheProcessMonitor ) Spawn (id string , process Process ) error {
4344 thisRef .procsSync .Lock ()
4445
4546 thisRef .procs [id ] = process
@@ -54,7 +55,11 @@ func (thisRef *WindowsProcessMonitor) Spawn(id string, process Process) error {
5455 })
5556 logging .Instance ().LogDebugWithFields (loggingC.Fields {
5657 "method" : helpersReflect .GetThisFuncName (),
57- "message" : fmt .Sprintf ("attempting to spawn details: %s" , thisRef .procs [id ]),
58+ "message" : fmt .Sprintf ("attempting to spawn details: %s" , thisRef .procs [id ].String ()),
59+ })
60+ logging .Instance ().LogDebugWithFields (loggingC.Fields {
61+ "method" : helpersReflect .GetThisFuncName (),
62+ "message" : fmt .Sprintf ("attempting to spawn CMD-WITH-ARGS: %s %s" , thisRef .procs [id ].Executable , strings .Join (thisRef .procs [id ].Args , " " )),
5863 })
5964
6065 // set working folder
@@ -101,7 +106,7 @@ func (thisRef *WindowsProcessMonitor) Spawn(id string, process Process) error {
101106}
102107
103108// Start -
104- func (thisRef * WindowsProcessMonitor ) Start (id string ) error {
109+ func (thisRef * TheProcessMonitor ) Start (id string ) error {
105110 if thisRef .GetProcessInfo (id ).IsRunning () {
106111 return nil
107112 }
@@ -131,7 +136,7 @@ func (thisRef *WindowsProcessMonitor) Start(id string) error {
131136}
132137
133138// Stop -
134- func (thisRef * WindowsProcessMonitor ) Stop (id string ) error {
139+ func (thisRef * TheProcessMonitor ) Stop (id string ) error {
135140 if ! thisRef .GetProcessInfo (id ).IsRunning () {
136141 return nil
137142 }
@@ -178,7 +183,7 @@ func (thisRef *WindowsProcessMonitor) Stop(id string) error {
178183}
179184
180185// Restart -
181- func (thisRef * WindowsProcessMonitor ) Restart (id string ) error {
186+ func (thisRef * TheProcessMonitor ) Restart (id string ) error {
182187 err := thisRef .Stop (id )
183188 if err != nil {
184189 return err
@@ -188,7 +193,7 @@ func (thisRef *WindowsProcessMonitor) Restart(id string) error {
188193}
189194
190195// StopAll -
191- func (thisRef * WindowsProcessMonitor ) StopAll () []error {
196+ func (thisRef * TheProcessMonitor ) StopAll () []error {
192197 thisRef .procsSync .RLock ()
193198 defer thisRef .procsSync .RUnlock ()
194199
@@ -207,15 +212,15 @@ func (thisRef *WindowsProcessMonitor) StopAll() []error {
207212}
208213
209214// GetProcessInfo -
210- func (thisRef * WindowsProcessMonitor ) GetProcessInfo (id string ) ProcessInfo {
215+ func (thisRef * TheProcessMonitor ) GetProcessInfo (id string ) ProcessInfo {
211216 thisRef .procsSync .RLock ()
212217 defer thisRef .procsSync .RUnlock ()
213218
214219 return thisRef .procsInfo [id ]
215220}
216221
217222// RemoveFromMonitor -
218- func (thisRef * WindowsProcessMonitor ) RemoveFromMonitor (id string ) {
223+ func (thisRef * TheProcessMonitor ) RemoveFromMonitor (id string ) {
219224 thisRef .procsSync .Lock ()
220225 defer thisRef .procsSync .Unlock ()
221226
@@ -229,7 +234,7 @@ func (thisRef *WindowsProcessMonitor) RemoveFromMonitor(id string) {
229234}
230235
231236// GetAll -
232- func (thisRef * WindowsProcessMonitor ) GetAll () []string {
237+ func (thisRef * TheProcessMonitor ) GetAll () []string {
233238 thisRef .procsSync .RLock ()
234239 defer thisRef .procsSync .RUnlock ()
235240
0 commit comments