-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
321bfee
commit 7d730c9
Showing
4 changed files
with
66 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright © 2016 Ramit Surana <[email protected]> | ||
// | ||
// 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 cmd | ||
|
||
import ( | ||
"fmt" | ||
"os/exec" | ||
"log" | ||
"github.com/spf13/cobra" | ||
"os" | ||
) | ||
|
||
var logCmd = &cobra.Command{ | ||
Use: "log", | ||
Short: "Uses logspout to collect your docker logs", | ||
Long: `Runs and configures logspout on your enviorment `, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
fmt.Println("Running logspout ...") | ||
cmd1 := exec.Command("docker", "run", "-d", | ||
"--volume=/var/run/docker.sock:/var/run/docker.sock", | ||
"--publish=127.0.0.1:8000:80", | ||
"gliderlabs/logspout") | ||
err1 := cmd1.Start() | ||
if err1 != nil { | ||
log.Fatal(err1) | ||
log.Printf("Failed to run logspout") | ||
os.Exit(1) | ||
} | ||
fmt.Println("Logspout has successfully collected logs.Try running curl http://127.0.0.1:8000/logs") | ||
}, | ||
} | ||
|
||
func init() { | ||
RootCmd.AddCommand(logCmd) | ||
} |
This file contains 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