mirror of
https://github.com/semaphoreui/semaphore.git
synced 2024-11-23 20:35:24 +01:00
Improved setup formatting
This commit is contained in:
parent
d5b1977889
commit
8fd27ee16b
@ -9,15 +9,17 @@ When creating a pull-request you should:
|
||||
# Installing dependencies
|
||||
|
||||
```
|
||||
go get -u ./...
|
||||
go get -u github.com/jteeuwen/go-bindata/...
|
||||
go get github.com/jteeuwen/go-bindata/...
|
||||
go get github.com/mitchellh/gox
|
||||
npm install -g nodemon less jade
|
||||
go get github.com/cespare/reflex
|
||||
go get -u ./...
|
||||
|
||||
npm i -g nodemon less jade
|
||||
```
|
||||
|
||||
# Running in development
|
||||
|
||||
```
|
||||
# edit config.json file
|
||||
$EDITOR config.json
|
||||
./make.sh watch
|
||||
```
|
38
README.md
38
README.md
@ -5,6 +5,44 @@
|
||||
Tests in progress.
|
||||
|
||||
## [Install Instructions](https://github.com/ansible-semaphore/semaphore/wiki/Installation)
|
||||
|
||||
## Common errors & pitfalls
|
||||
|
||||
```
|
||||
Cannot connect to database!
|
||||
Error 1045: Access denied for user 'root'@'localhost' (using password: NO)
|
||||
```
|
||||
|
||||
Your password for database is empty and is required.
|
||||
|
||||
---
|
||||
|
||||
```
|
||||
Database migrations failed!
|
||||
... error here ...
|
||||
```
|
||||
|
||||
Please open an issue, tell us you database version & configuration.
|
||||
|
||||
---
|
||||
|
||||
```
|
||||
PING to redis unsuccessful
|
||||
... panic here ...
|
||||
```
|
||||
|
||||
The program cannot reach your redis instance. Check the configuration and test manually with:
|
||||
|
||||
```
|
||||
nc <IP> 6379
|
||||
PING
|
||||
+PONG
|
||||
```
|
||||
|
||||
if `netcat` returns immediately, the port is not reachable.
|
||||
|
||||
---
|
||||
|
||||
## [Milestones](https://github.com/ansible-semaphore/semaphore/milestones)
|
||||
## [Releases](https://github.com/ansible-semaphore/semaphore/releases)
|
||||
|
||||
|
@ -5,12 +5,12 @@ dependencies:
|
||||
main'
|
||||
- sudo apt-get update; sudo DEBIAN_FRONTEND=noninteractive apt-get
|
||||
install -y mysql-server-5.6
|
||||
- go get github.com/tools/godep
|
||||
- go get github.com/jteeuwen/go-bindata/...
|
||||
- godep restore
|
||||
- go get github.com/mitchellh/gox
|
||||
- go get github.com/cespare/reflex
|
||||
|
||||
override:
|
||||
- mkdir -p "/home/ubuntu/.go_workspace/src/github.com/castawaylabs"
|
||||
- mkdir -p "/home/ubuntu/.go_workspace/src/github.com/ansible-semaphore"
|
||||
- ln -fs /home/ubuntu/semaphore /home/ubuntu/.go_workspace/src/github.com/ansible-semaphore
|
||||
|
||||
test:
|
||||
|
@ -24,11 +24,11 @@ func Connect() error {
|
||||
}
|
||||
|
||||
if _, err := db.Exec("create database if not exists " + util.Config.MySQL.DbName); err != nil {
|
||||
panic(err)
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err := db.Exec("use " + util.Config.MySQL.DbName); err != nil {
|
||||
panic(err)
|
||||
return err
|
||||
}
|
||||
|
||||
Mysql = &gorp.DbMap{Db: db, Dialect: gorp.MySQLDialect{Engine: "InnoDB", Encoding: "UTF8"}}
|
||||
|
65
main.go
65
main.go
@ -8,8 +8,6 @@ import (
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
|
||||
"github.com/ansible-semaphore/semaphore/database"
|
||||
"github.com/ansible-semaphore/semaphore/migration"
|
||||
"github.com/ansible-semaphore/semaphore/models"
|
||||
@ -20,6 +18,7 @@ import (
|
||||
"github.com/ansible-semaphore/semaphore/util"
|
||||
"github.com/bugsnag/bugsnag-go"
|
||||
"github.com/gin-gonic/gin"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -76,13 +75,13 @@ func recovery(c *gin.Context) {
|
||||
|
||||
func doSetup() int {
|
||||
fmt.Print(`
|
||||
Hello, you will now be guided through a setup to:
|
||||
Hello! You will now be guided through a setup to:
|
||||
|
||||
- Set up configuration for a MySQL/MariaDB database
|
||||
- Set up redis for session storage
|
||||
- Set up a path for your playbooks
|
||||
- Run DB Migrations
|
||||
- Set up your user and password
|
||||
1. Set up configuration for a MySQL/MariaDB database
|
||||
2. Set up redis for session storage
|
||||
3. Set up a path for your playbooks (auto-created)
|
||||
4. Run database Migrations
|
||||
5. Set up initial seamphore user & password
|
||||
|
||||
`)
|
||||
|
||||
@ -95,58 +94,56 @@ Hello, you will now be guided through a setup to:
|
||||
panic(err)
|
||||
}
|
||||
|
||||
fmt.Printf("Config:\n%v\n\n", string(b))
|
||||
fmt.Print("Is this correct? (yes/no): ")
|
||||
fmt.Printf("\n Generated configuration:\n %v\n\n", string(b))
|
||||
fmt.Print(" > Is this correct? (yes/no): ")
|
||||
|
||||
var answer string
|
||||
fmt.Scanln(&answer)
|
||||
|
||||
if !(answer == "yes" || answer == "y") {
|
||||
fmt.Println()
|
||||
setup = util.ScanSetup()
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
if answer == "yes" || answer == "y" {
|
||||
break
|
||||
}
|
||||
|
||||
fmt.Printf("Running: mkdir -p %v\n", setup.TmpPath)
|
||||
fmt.Println()
|
||||
setup = util.ScanSetup()
|
||||
}
|
||||
|
||||
fmt.Printf(" Running: mkdir -p %v..\n", setup.TmpPath)
|
||||
os.MkdirAll(setup.TmpPath, 0755)
|
||||
|
||||
configPath := path.Join(setup.TmpPath, "/semaphore_config.json")
|
||||
fmt.Printf("Configuration written to %v\n", setup.TmpPath)
|
||||
fmt.Printf(" Configuration written to %v..\n", setup.TmpPath)
|
||||
if err := ioutil.WriteFile(configPath, b, 0644); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
fmt.Println("\nPinging database...")
|
||||
fmt.Println(" Pinging database..")
|
||||
util.Config = setup
|
||||
|
||||
if err := database.Connect(); err != nil {
|
||||
fmt.Println("Connection to database unsuccessful.")
|
||||
panic(err)
|
||||
fmt.Printf("\n Cannot connect to database!\n %v\n", err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
fmt.Println("Pinging redis...")
|
||||
fmt.Println(" Pinging redis..")
|
||||
database.RedisPing()
|
||||
|
||||
fmt.Println("\nRunning DB Migrations")
|
||||
fmt.Println("\n Running DB Migrations..")
|
||||
if err := migration.MigrateAll(); err != nil {
|
||||
panic(err)
|
||||
fmt.Printf("\n Database migrations failed!\n %v\n", err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
var user models.User
|
||||
fmt.Print("\n\nYour name: ")
|
||||
fmt.Print("\n\n > Your name: ")
|
||||
fmt.Scanln(&user.Name)
|
||||
|
||||
fmt.Print("Username: ")
|
||||
fmt.Print(" > Username: ")
|
||||
fmt.Scanln(&user.Username)
|
||||
|
||||
fmt.Print("Email: ")
|
||||
fmt.Print(" > Email: ")
|
||||
fmt.Scanln(&user.Email)
|
||||
|
||||
fmt.Print("Password: ")
|
||||
fmt.Print(" > Password: ")
|
||||
fmt.Scanln(&user.Password)
|
||||
|
||||
pwdHash, _ := bcrypt.GenerateFromPassword([]byte(user.Password), 11)
|
||||
@ -154,11 +151,13 @@ Hello, you will now be guided through a setup to:
|
||||
user.Email = strings.ToLower(user.Email)
|
||||
|
||||
if _, err := database.Mysql.Exec("insert into user set name=?, username=?, email=?, password=?, created=NOW()", user.Name, user.Username, user.Email, pwdHash); err != nil {
|
||||
panic(err)
|
||||
fmt.Printf(" Inserting user failed. If you already have a user, you can disregard this error.\n %v\n", err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
fmt.Printf("\nYou are all setup %v\n", user.Name)
|
||||
fmt.Printf("Re-launch this program pointing to the configuration file\n./semaphore -config %v\n", configPath)
|
||||
fmt.Printf("\n You are all setup %v!\n", user.Name)
|
||||
fmt.Printf(" Re-launch this program pointing to the configuration file\n\n./semaphore -config %v\n\n", configPath)
|
||||
fmt.Printf(" To run as daemon:\n\nnohup ./semaphore -config %v &\n\n", configPath)
|
||||
fmt.Println(" Your login is %v or %v.", user.Email, user.Username)
|
||||
|
||||
return 0
|
||||
|
6
make.sh
6
make.sh
@ -54,7 +54,11 @@ if [ "$1" == "watch" ]; then
|
||||
|
||||
nodemon -w js -i bundle.js -e js bundler.js &
|
||||
nodemon -w css -e less --exec "lessc css/semaphore.less > css/semaphore.css" &
|
||||
jade -w -P html/*.jade html/*/*.jade html/*/*/*.jade
|
||||
jade -w -P html/*.jade html/*/*.jade html/*/*/*.jade &
|
||||
|
||||
cd ../
|
||||
reflex -r '\.go$' -s -d none -- sh -c 'go run main.go'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
gox -os="linux darwin windows openbsd" ./...
|
@ -165,34 +165,34 @@ func MandrillSend(message gochimp.Message) ([]gochimp.SendResponse, error) {
|
||||
func ScanSetup() configType {
|
||||
var conf configType
|
||||
|
||||
fmt.Print("DB Hostname (default 127.0.0.1:3306): ")
|
||||
fmt.Print(" > DB Hostname (default 127.0.0.1:3306): ")
|
||||
fmt.Scanln(&conf.MySQL.Hostname)
|
||||
if len(conf.MySQL.Hostname) == 0 {
|
||||
conf.MySQL.Hostname = "127.0.0.1:3306"
|
||||
}
|
||||
|
||||
fmt.Print("DB User (default root): ")
|
||||
fmt.Print(" > DB User (default root): ")
|
||||
fmt.Scanln(&conf.MySQL.Username)
|
||||
if len(conf.MySQL.Username) == 0 {
|
||||
conf.MySQL.Username = "root"
|
||||
}
|
||||
|
||||
fmt.Print("DB Password: ")
|
||||
fmt.Print(" > DB Password: ")
|
||||
fmt.Scanln(&conf.MySQL.Password)
|
||||
|
||||
fmt.Print("DB Name (default semaphore): ")
|
||||
fmt.Print(" > DB Name (default semaphore): ")
|
||||
fmt.Scanln(&conf.MySQL.DbName)
|
||||
if len(conf.MySQL.DbName) == 0 {
|
||||
conf.MySQL.DbName = "semaphore"
|
||||
}
|
||||
|
||||
fmt.Print("Redis Connection (default 127.0.0.1:6379): ")
|
||||
fmt.Print(" > Redis Connection (default 127.0.0.1:6379): ")
|
||||
fmt.Scanln(&conf.SessionDb)
|
||||
if len(conf.SessionDb) == 0 {
|
||||
conf.SessionDb = "127.0.0.1:6379"
|
||||
}
|
||||
|
||||
fmt.Print("Playbook path (will be auto-created if does not exist): ")
|
||||
fmt.Print(" > Playbook path: ")
|
||||
fmt.Scanln(&conf.TmpPath)
|
||||
|
||||
if len(conf.TmpPath) == 0 {
|
||||
|
Loading…
Reference in New Issue
Block a user