Last active
September 6, 2017 16:05
-
-
Save dafma/ca7b732f642f34af8cb5366a2b9503fa to your computer and use it in GitHub Desktop.
ejecutar e iniciar instancia de djnago con python y golng
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os/exec" | |
"io" | |
"bufio" | |
"os" | |
) | |
func main() { | |
cmd := exec.Command("python", "manage.py", "runserver") | |
stdout, err := cmd.StdoutPipe() | |
if err != nil { | |
panic(err) | |
} | |
stderr, err := cmd.StderrPipe() | |
if err != nil { | |
panic(err) | |
} | |
err = cmd.Start() | |
if err != nil { | |
panic(err) | |
} | |
go copyOutput(stdout) | |
go copyOutput(stderr) | |
cmd.Wait() | |
fmt.Print("Press 'Enter' to continue...") | |
bufio.NewReader(os.Stdin).ReadBytes('\n') | |
} | |
func copyOutput(r io.Reader) { | |
scanner := bufio.NewScanner(r) | |
for scanner.Scan() { | |
fmt.Println(scanner.Text()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment