mirror of https://github.com/statping/statping
				
				
				
			
							parent
							
								
									b4ee5ae514
								
							
						
					
					
						commit
						473419fefb
					
				|  | @ -0,0 +1,33 @@ | ||||||
|  | ########################### | ||||||
|  | ##  Database Information  # | ||||||
|  | ########################### | ||||||
|  | DB_CONNECTION=postgres | ||||||
|  | DB_HOST=localhost | ||||||
|  | DB_PORT=5432 | ||||||
|  | DB_USER=root | ||||||
|  | DB_PASS=password123 | ||||||
|  | DB_DATABASE=root | ||||||
|  | 
 | ||||||
|  | ########################### | ||||||
|  | ##  STATUP PAGE SETTINGS  # | ||||||
|  | ########################### | ||||||
|  | NAME=Demo | ||||||
|  | DESCRIPTION=This is an awesome page | ||||||
|  | DOMAIN=https://domain.com | ||||||
|  | ADMIN_USER=admin | ||||||
|  | ADMIN_PASS=admin | ||||||
|  | ADMIN_EMAIL=info@admin.com | ||||||
|  | USE_CDN=true | ||||||
|  | 
 | ||||||
|  | ########################### | ||||||
|  | ##     System Values     ## | ||||||
|  | ########################### | ||||||
|  | IS_DOCKER=true | ||||||
|  | IS_AWS=true | ||||||
|  | SASS=/usr/local/bin/sass | ||||||
|  | BASH_ENV=/bin/bash | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | @ -18,7 +18,7 @@ services: | ||||||
| 
 | 
 | ||||||
| env: | env: | ||||||
|   global: |   global: | ||||||
|      - VERSION=0.27 |      - VERSION=0.27.1 | ||||||
|      - DB_HOST=localhost |      - DB_HOST=localhost | ||||||
|      - DB_USER=travis |      - DB_USER=travis | ||||||
|      - DB_PASS= |      - DB_PASS= | ||||||
|  |  | ||||||
|  | @ -2,9 +2,9 @@ | ||||||
| 
 | 
 | ||||||
| APP="statup" | APP="statup" | ||||||
| REPO="hunterlong/statup" | REPO="hunterlong/statup" | ||||||
| SASS=1.7.1 |  | ||||||
| 
 | 
 | ||||||
| # COMPILE BOOTSTRAP | # COMPILE BOOTSTRAP | ||||||
|  | rm -rf bootstrap | ||||||
| git clone https://github.com/twbs/bootstrap.git | git clone https://github.com/twbs/bootstrap.git | ||||||
| cd bootstrap | cd bootstrap | ||||||
| npm install | npm install | ||||||
|  | @ -16,7 +16,7 @@ cd ../ | ||||||
| rm -rf bootstrap | rm -rf bootstrap | ||||||
| 
 | 
 | ||||||
| # RENDERING CSS | # RENDERING CSS | ||||||
| gem install sass | #gem install sass | ||||||
| sass html/scss/base.scss html/css/base.css | sass html/scss/base.scss html/css/base.css | ||||||
| 
 | 
 | ||||||
| # MIGRATION SQL FILE FOR CURRENT VERSION | # MIGRATION SQL FILE FOR CURRENT VERSION | ||||||
|  |  | ||||||
|  | @ -15,6 +15,7 @@ RUN wget https://assets.statup.io/sass && \ | ||||||
|       chmod +x sass && \ |       chmod +x sass && \ | ||||||
|       mv sass /usr/local/bin/sass |       mv sass /usr/local/bin/sass | ||||||
| 
 | 
 | ||||||
|  | ENV SASS=/usr/local/bin/sass | ||||||
| ENV CMD_FILE=/usr/bin/cmd | ENV CMD_FILE=/usr/bin/cmd | ||||||
| RUN printf "#!/usr/bin/env sh\n\$1\n" > $CMD_FILE && \ | RUN printf "#!/usr/bin/env sh\n\$1\n" > $CMD_FILE && \ | ||||||
|       chmod +x $CMD_FILE |       chmod +x $CMD_FILE | ||||||
|  |  | ||||||
|  | @ -30,9 +30,11 @@ func MakePublicFolder(folder string) { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func CompileSASS() { | func CompileSASS() { | ||||||
| 	cmdBin := os.Getenv("CMD_FILE") | 	cmdBin := os.Getenv("SASS") | ||||||
|  | 	shell := os.Getenv("BASH_ENV") | ||||||
| 	fmt.Println("Compiling SASS into /css/base.css...") | 	fmt.Println("Compiling SASS into /css/base.css...") | ||||||
| 	testCmd := exec.Command(cmdBin, "sass assets/scss/base.scss assets/css/base.css") | 	command := fmt.Sprintf("%v %v %v", cmdBin, "assets/scss/base.scss", "assets/css/base.css") | ||||||
|  | 	testCmd := exec.Command(shell, command) | ||||||
| 	_, err := testCmd.Output() | 	_, err := testCmd.Output() | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		fmt.Println(err) | 		fmt.Println(err) | ||||||
|  |  | ||||||
							
								
								
									
										34
									
								
								cli.go
								
								
								
								
							
							
						
						
									
										34
									
								
								cli.go
								
								
								
								
							|  | @ -2,6 +2,7 @@ package main | ||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
|  | 	"github.com/joho/godotenv" | ||||||
| 	"os" | 	"os" | ||||||
| 	"time" | 	"time" | ||||||
| ) | ) | ||||||
|  | @ -29,6 +30,39 @@ func CatchCLI(args []string) { | ||||||
| 		HelpEcho() | 		HelpEcho() | ||||||
| 	case "update": | 	case "update": | ||||||
| 		fmt.Println("Sorry updating isn't available yet!") | 		fmt.Println("Sorry updating isn't available yet!") | ||||||
|  | 	case "run": | ||||||
|  | 		fmt.Println("Running 1 time and saving to database...") | ||||||
|  | 
 | ||||||
|  | 		var err error | ||||||
|  | 		configs, err = LoadConfig() | ||||||
|  | 		if err != nil { | ||||||
|  | 			fmt.Println("config.yml file not found") | ||||||
|  | 			os.Exit(1) | ||||||
|  | 		} | ||||||
|  | 		err = DbConnection(configs.Connection) | ||||||
|  | 		if err != nil { | ||||||
|  | 			throw(err) | ||||||
|  | 		} | ||||||
|  | 		core, err = SelectCore() | ||||||
|  | 		if err != nil { | ||||||
|  | 			fmt.Println("Core database was not found, Statup is not setup yet.") | ||||||
|  | 		} | ||||||
|  | 		services, _ = SelectAllServices() | ||||||
|  | 		for _, s := range services { | ||||||
|  | 			out := s.Check() | ||||||
|  | 			fmt.Printf("    Service %v | URL: %v | Latency: %0.0fms | Online: %v\n", out.Name, out.Domain, (out.Latency * 1000), out.Online) | ||||||
|  | 		} | ||||||
|  | 		fmt.Println("Check is complete.") | ||||||
|  | 	case "env": | ||||||
|  | 		fmt.Println("Statup Environment Variables") | ||||||
|  | 		envs, err := godotenv.Read(".env") | ||||||
|  | 		if err != nil { | ||||||
|  | 			fmt.Println("No .env file found in current directory.") | ||||||
|  | 			os.Exit(1) | ||||||
|  | 		} | ||||||
|  | 		for k, e := range envs { | ||||||
|  | 			fmt.Printf("%v=%v\n", k, e) | ||||||
|  | 		} | ||||||
| 	default: | 	default: | ||||||
| 		fmt.Println("Statup does not have the command you entered.") | 		fmt.Println("Statup does not have the command you entered.") | ||||||
| 		os.Exit(1) | 		os.Exit(1) | ||||||
|  |  | ||||||
							
								
								
									
										22
									
								
								errors.go
								
								
								
								
							
							
						
						
									
										22
									
								
								errors.go
								
								
								
								
							|  | @ -1,22 +0,0 @@ | ||||||
| package main |  | ||||||
| 
 |  | ||||||
| import ( |  | ||||||
| 	"fmt" |  | ||||||
| 	"strings" |  | ||||||
| ) |  | ||||||
| 
 |  | ||||||
| func (f *Failure) ParseError() string { |  | ||||||
| 	err := strings.Contains(f.Issue, "operation timed out") |  | ||||||
| 	if err { |  | ||||||
| 		return fmt.Sprintf("HTTP Request Timed Out") |  | ||||||
| 	} |  | ||||||
| 	err = strings.Contains(f.Issue, "x509: certificate is valid") |  | ||||||
| 	if err { |  | ||||||
| 		return fmt.Sprintf("SSL Certificate invalid") |  | ||||||
| 	} |  | ||||||
| 	err = strings.Contains(f.Issue, "no such host") |  | ||||||
| 	if err { |  | ||||||
| 		return fmt.Sprintf("Domain is offline or not found") |  | ||||||
| 	} |  | ||||||
| 	return f.Issue |  | ||||||
| } |  | ||||||
|  | @ -1,15 +1,3 @@ | ||||||
| /* |  | ||||||
|       Main Design |  | ||||||
|    ================= |  | ||||||
|     - Background |  | ||||||
|     - Boxes |  | ||||||
|     - Font Colors |  | ||||||
|     - div widths |  | ||||||
| */ |  | ||||||
| /* |  | ||||||
|     Card Design |  | ||||||
|   ================ |  | ||||||
| */ |  | ||||||
| HTML, BODY { | HTML, BODY { | ||||||
|     background-color: #fcfcfc; |     background-color: #fcfcfc; | ||||||
| } | } | ||||||
|  | @ -231,5 +219,3 @@ HTML, BODY { | ||||||
|         border-bottom-left-radius: 0; |         border-bottom-left-radius: 0; | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 |  | ||||||
| /*# sourceMappingURL=base.css.map */ |  | ||||||
|  |  | ||||||
|  | @ -1,4 +1,4 @@ | ||||||
| @import 'variables'; | @import '_variables'; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| HTML,BODY { | HTML,BODY { | ||||||
|  |  | ||||||
|  | @ -1,28 +0,0 @@ | ||||||
| /* |  | ||||||
|       Main Design |  | ||||||
|    ================= |  | ||||||
|     - Background |  | ||||||
|     - Boxes |  | ||||||
|     - Font Colors |  | ||||||
|     - div widths |  | ||||||
| */ |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| $background-color: #fcfcfc; |  | ||||||
| $max-width: 860px; |  | ||||||
| $online-color: #47d337; |  | ||||||
| $offline-color: #dd3545; |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| /* |  | ||||||
|     Card Design |  | ||||||
|   ================ |  | ||||||
| */ |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| $card-background: #fff; |  | ||||||
| $card-stats-color: #474747; |  | ||||||
| $card-stats-size: 26pt; |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
							
								
								
									
										8
									
								
								main.go
								
								
								
								
							
							
						
						
									
										8
									
								
								main.go
								
								
								
								
							|  | @ -7,6 +7,7 @@ import ( | ||||||
| 	"github.com/go-yaml/yaml" | 	"github.com/go-yaml/yaml" | ||||||
| 	"github.com/gorilla/sessions" | 	"github.com/gorilla/sessions" | ||||||
| 	"github.com/hunterlong/statup/plugin" | 	"github.com/hunterlong/statup/plugin" | ||||||
|  | 	"github.com/joho/godotenv" | ||||||
| 	"golang.org/x/crypto/bcrypt" | 	"golang.org/x/crypto/bcrypt" | ||||||
| 	"io" | 	"io" | ||||||
| 	"io/ioutil" | 	"io/ioutil" | ||||||
|  | @ -92,6 +93,13 @@ func DownloadFile(filepath string, url string) error { | ||||||
| 	return nil | 	return nil | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | func init() { | ||||||
|  | 	err := godotenv.Load() | ||||||
|  | 	if err != nil { | ||||||
|  | 		fmt.Println("Error loading .env file") | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
| func main() { | func main() { | ||||||
| 	if len(os.Args) >= 2 { | 	if len(os.Args) >= 2 { | ||||||
| 		CatchCLI(os.Args) | 		CatchCLI(os.Args) | ||||||
|  |  | ||||||
										
											Binary file not shown.
										
									
								
							|  | @ -95,11 +95,6 @@ func (s *Service) Online24() float32 { | ||||||
| 	return s.Online24Hours | 	return s.Online24Hours | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| type GraphJson struct { |  | ||||||
| 	X string  `json:"x"` |  | ||||||
| 	Y float64 `json:"y"` |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| type DateScan struct { | type DateScan struct { | ||||||
| 	CreatedAt time.Time `json:"x"` | 	CreatedAt time.Time `json:"x"` | ||||||
| 	Value     int64     `json:"y"` | 	Value     int64     `json:"y"` | ||||||
|  |  | ||||||
|  | @ -6,9 +6,24 @@ import ( | ||||||
| 	"html/template" | 	"html/template" | ||||||
| 	"io/ioutil" | 	"io/ioutil" | ||||||
| 	"log" | 	"log" | ||||||
|  | 	"strings" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| var httpFunctions template.FuncMap | func (f *Failure) ParseError() string { | ||||||
|  | 	err := strings.Contains(f.Issue, "operation timed out") | ||||||
|  | 	if err { | ||||||
|  | 		return fmt.Sprintf("HTTP Request Timed Out") | ||||||
|  | 	} | ||||||
|  | 	err = strings.Contains(f.Issue, "x509: certificate is valid") | ||||||
|  | 	if err { | ||||||
|  | 		return fmt.Sprintf("SSL Certificate invalid") | ||||||
|  | 	} | ||||||
|  | 	err = strings.Contains(f.Issue, "no such host") | ||||||
|  | 	if err { | ||||||
|  | 		return fmt.Sprintf("Domain is offline or not found") | ||||||
|  | 	} | ||||||
|  | 	return f.Issue | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| func ExportIndexHTML() string { | func ExportIndexHTML() string { | ||||||
| 	core.OfflineAssets = true | 	core.OfflineAssets = true | ||||||
		Loading…
	
		Reference in New Issue
	
	 Hunter Long
						Hunter Long