parent
52ac079b7b
commit
0705305a4d
@ -0,0 +1,39 @@
|
||||
# kexec
|
||||
[![GoDoc](https://godoc.org/github.com/codeskyblue/kexec?status.svg)](https://godoc.org/github.com/codeskyblue/kexec)
|
||||
|
||||
This is a golang lib, add a `Terminate` command to exec.
|
||||
|
||||
Tested on _windows, linux, darwin._
|
||||
|
||||
This lib has been used in [fswatch](https://github.com/codeskyblue/fswatch).
|
||||
|
||||
## Usage
|
||||
|
||||
go get -v github.com/codeskyblue/kexec
|
||||
|
||||
|
||||
example1:
|
||||
|
||||
package main
|
||||
|
||||
import "github.com/codeskyblue/kexec"
|
||||
|
||||
func main(){
|
||||
p := kexec.Command("python", "flask_main.py")
|
||||
p.Start()
|
||||
p.Terminate(syscall.SIGINT)
|
||||
}
|
||||
|
||||
example2: see more [examples](examples)
|
||||
|
||||
package main
|
||||
|
||||
import "github.com/codeskyblue/kexec"
|
||||
|
||||
func main() {
|
||||
// In unix will call: bash -c "python flask_main.py"
|
||||
// In windows will call: cmd /c "python flask_main.py"
|
||||
p := kexec.CommandString("python flask_main.py")
|
||||
p.Start()
|
||||
p.Terminate(syscall.SIGKILL)
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/codeskyblue/kexec"
|
||||
)
|
||||
|
||||
func main() {
|
||||
p := kexec.CommandString("python flask_main.py")
|
||||
p.Start()
|
||||
time.Sleep(3 * time.Second)
|
||||
err := p.Terminate(syscall.SIGKILL)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
import flask
|
||||
|
||||
app = flask.Flask(__name__)
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(port=46732, debug=True)
|
@ -0,0 +1,7 @@
|
||||
package kexec
|
||||
|
||||
import "os/exec"
|
||||
|
||||
type KCommand struct {
|
||||
*exec.Cmd
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
# kproc
|
||||
[![GoDoc](https://godoc.org/github.com/codeskyblue/kproc?status.svg)](https://godoc.org/github.com/codeskyblue/kproc)
|
||||
|
||||
# Now have been moved to [kexec](https://github.com/codeskyblue/kexec)
|
||||
|
||||
This lib is not maintained any more. **!!!**
|
||||
|
||||
----------
|
||||
|
||||
This is a golang lib, offer a better way to kill all child process.
|
||||
|
||||
Tested on _windows, linux, darwin._
|
||||
|
||||
This lib has been used in [fswatch](https://github.com/codeskyblue/fswatch).
|
||||
|
||||
## Usage
|
||||
|
||||
go get -v github.com/codeskyblue/kproc
|
||||
|
||||
example:
|
||||
|
||||
func main() {
|
||||
p := kproc.ProcString("python flask_main.py")
|
||||
p.Start()
|
||||
time.Sleep(3 * time.Second)
|
||||
err := p.Terminate(syscall.SIGKILL)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
package kproc
|
||||
|
||||
import "os/exec"
|
||||
|
||||
type Process struct {
|
||||
*exec.Cmd
|
||||
}
|
Loading…
Reference in new issue