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
|
# Installing dependencies
|
||||||
|
|
||||||
```
|
```
|
||||||
go get -u ./...
|
go get github.com/jteeuwen/go-bindata/...
|
||||||
go get -u github.com/jteeuwen/go-bindata/...
|
|
||||||
go get github.com/mitchellh/gox
|
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
|
# Running in development
|
||||||
|
|
||||||
```
|
```
|
||||||
# edit config.json file
|
$EDITOR config.json
|
||||||
./make.sh watch
|
./make.sh watch
|
||||||
```
|
```
|
38
README.md
38
README.md
@ -5,6 +5,44 @@
|
|||||||
Tests in progress.
|
Tests in progress.
|
||||||
|
|
||||||
## [Install Instructions](https://github.com/ansible-semaphore/semaphore/wiki/Installation)
|
## [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)
|
## [Milestones](https://github.com/ansible-semaphore/semaphore/milestones)
|
||||||
## [Releases](https://github.com/ansible-semaphore/semaphore/releases)
|
## [Releases](https://github.com/ansible-semaphore/semaphore/releases)
|
||||||
|
|
||||||
|
@ -5,12 +5,12 @@ dependencies:
|
|||||||
main'
|
main'
|
||||||
- sudo apt-get update; sudo DEBIAN_FRONTEND=noninteractive apt-get
|
- sudo apt-get update; sudo DEBIAN_FRONTEND=noninteractive apt-get
|
||||||
install -y mysql-server-5.6
|
install -y mysql-server-5.6
|
||||||
- go get github.com/tools/godep
|
|
||||||
- go get github.com/jteeuwen/go-bindata/...
|
- go get github.com/jteeuwen/go-bindata/...
|
||||||
- godep restore
|
- go get github.com/mitchellh/gox
|
||||||
|
- go get github.com/cespare/reflex
|
||||||
|
|
||||||
override:
|
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
|
- ln -fs /home/ubuntu/semaphore /home/ubuntu/.go_workspace/src/github.com/ansible-semaphore
|
||||||
|
|
||||||
test:
|
test:
|
||||||
|
@ -24,11 +24,11 @@ func Connect() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if _, err := db.Exec("create database if not exists " + util.Config.MySQL.DbName); err != nil {
|
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 {
|
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"}}
|
Mysql = &gorp.DbMap{Db: db, Dialect: gorp.MySQLDialect{Engine: "InnoDB", Encoding: "UTF8"}}
|
||||||
|
67
main.go
67
main.go
@ -8,8 +8,6 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"golang.org/x/crypto/bcrypt"
|
|
||||||
|
|
||||||
"github.com/ansible-semaphore/semaphore/database"
|
"github.com/ansible-semaphore/semaphore/database"
|
||||||
"github.com/ansible-semaphore/semaphore/migration"
|
"github.com/ansible-semaphore/semaphore/migration"
|
||||||
"github.com/ansible-semaphore/semaphore/models"
|
"github.com/ansible-semaphore/semaphore/models"
|
||||||
@ -20,6 +18,7 @@ import (
|
|||||||
"github.com/ansible-semaphore/semaphore/util"
|
"github.com/ansible-semaphore/semaphore/util"
|
||||||
"github.com/bugsnag/bugsnag-go"
|
"github.com/bugsnag/bugsnag-go"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"golang.org/x/crypto/bcrypt"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -76,13 +75,13 @@ func recovery(c *gin.Context) {
|
|||||||
|
|
||||||
func doSetup() int {
|
func doSetup() int {
|
||||||
fmt.Print(`
|
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
|
1. Set up configuration for a MySQL/MariaDB database
|
||||||
- Set up redis for session storage
|
2. Set up redis for session storage
|
||||||
- Set up a path for your playbooks
|
3. Set up a path for your playbooks (auto-created)
|
||||||
- Run DB Migrations
|
4. Run database Migrations
|
||||||
- Set up your user and password
|
5. Set up initial seamphore user & password
|
||||||
|
|
||||||
`)
|
`)
|
||||||
|
|
||||||
@ -90,63 +89,61 @@ Hello, you will now be guided through a setup to:
|
|||||||
setup := util.ScanSetup()
|
setup := util.ScanSetup()
|
||||||
for true {
|
for true {
|
||||||
var err error
|
var err error
|
||||||
b, err = json.MarshalIndent(&setup, "", "\t")
|
b, err = json.MarshalIndent(&setup, " ", "\t")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("Config:\n%v\n\n", string(b))
|
fmt.Printf("\n Generated configuration:\n %v\n\n", string(b))
|
||||||
fmt.Print("Is this correct? (yes/no): ")
|
fmt.Print(" > Is this correct? (yes/no): ")
|
||||||
|
|
||||||
var answer string
|
var answer string
|
||||||
fmt.Scanln(&answer)
|
fmt.Scanln(&answer)
|
||||||
|
if answer == "yes" || answer == "y" {
|
||||||
if !(answer == "yes" || answer == "y") {
|
break
|
||||||
fmt.Println()
|
|
||||||
setup = util.ScanSetup()
|
|
||||||
|
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break
|
fmt.Println()
|
||||||
|
setup = util.ScanSetup()
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("Running: mkdir -p %v\n", setup.TmpPath)
|
fmt.Printf(" Running: mkdir -p %v..\n", setup.TmpPath)
|
||||||
os.MkdirAll(setup.TmpPath, 0755)
|
os.MkdirAll(setup.TmpPath, 0755)
|
||||||
|
|
||||||
configPath := path.Join(setup.TmpPath, "/semaphore_config.json")
|
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 {
|
if err := ioutil.WriteFile(configPath, b, 0644); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("\nPinging database...")
|
fmt.Println(" Pinging database..")
|
||||||
util.Config = setup
|
util.Config = setup
|
||||||
|
|
||||||
if err := database.Connect(); err != nil {
|
if err := database.Connect(); err != nil {
|
||||||
fmt.Println("Connection to database unsuccessful.")
|
fmt.Printf("\n Cannot connect to database!\n %v\n", err.Error())
|
||||||
panic(err)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("Pinging redis...")
|
fmt.Println(" Pinging redis..")
|
||||||
database.RedisPing()
|
database.RedisPing()
|
||||||
|
|
||||||
fmt.Println("\nRunning DB Migrations")
|
fmt.Println("\n Running DB Migrations..")
|
||||||
if err := migration.MigrateAll(); err != nil {
|
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
|
var user models.User
|
||||||
fmt.Print("\n\nYour name: ")
|
fmt.Print("\n\n > Your name: ")
|
||||||
fmt.Scanln(&user.Name)
|
fmt.Scanln(&user.Name)
|
||||||
|
|
||||||
fmt.Print("Username: ")
|
fmt.Print(" > Username: ")
|
||||||
fmt.Scanln(&user.Username)
|
fmt.Scanln(&user.Username)
|
||||||
|
|
||||||
fmt.Print("Email: ")
|
fmt.Print(" > Email: ")
|
||||||
fmt.Scanln(&user.Email)
|
fmt.Scanln(&user.Email)
|
||||||
|
|
||||||
fmt.Print("Password: ")
|
fmt.Print(" > Password: ")
|
||||||
fmt.Scanln(&user.Password)
|
fmt.Scanln(&user.Password)
|
||||||
|
|
||||||
pwdHash, _ := bcrypt.GenerateFromPassword([]byte(user.Password), 11)
|
pwdHash, _ := bcrypt.GenerateFromPassword([]byte(user.Password), 11)
|
||||||
@ -154,12 +151,14 @@ Hello, you will now be guided through a setup to:
|
|||||||
user.Email = strings.ToLower(user.Email)
|
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 {
|
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("\n You 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(" Re-launch this program pointing to the configuration file\n\n./semaphore -config %v\n\n", configPath)
|
||||||
fmt.Println("Your login is %v or %v.", user.Email, user.Username)
|
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
|
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 js -i bundle.js -e js bundler.js &
|
||||||
nodemon -w css -e less --exec "lessc css/semaphore.less > css/semaphore.css" &
|
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
|
fi
|
||||||
|
|
||||||
gox -os="linux darwin windows openbsd" ./...
|
gox -os="linux darwin windows openbsd" ./...
|
@ -165,34 +165,34 @@ func MandrillSend(message gochimp.Message) ([]gochimp.SendResponse, error) {
|
|||||||
func ScanSetup() configType {
|
func ScanSetup() configType {
|
||||||
var conf 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)
|
fmt.Scanln(&conf.MySQL.Hostname)
|
||||||
if len(conf.MySQL.Hostname) == 0 {
|
if len(conf.MySQL.Hostname) == 0 {
|
||||||
conf.MySQL.Hostname = "127.0.0.1:3306"
|
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)
|
fmt.Scanln(&conf.MySQL.Username)
|
||||||
if len(conf.MySQL.Username) == 0 {
|
if len(conf.MySQL.Username) == 0 {
|
||||||
conf.MySQL.Username = "root"
|
conf.MySQL.Username = "root"
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Print("DB Password: ")
|
fmt.Print(" > DB Password: ")
|
||||||
fmt.Scanln(&conf.MySQL.Password)
|
fmt.Scanln(&conf.MySQL.Password)
|
||||||
|
|
||||||
fmt.Print("DB Name (default semaphore): ")
|
fmt.Print(" > DB Name (default semaphore): ")
|
||||||
fmt.Scanln(&conf.MySQL.DbName)
|
fmt.Scanln(&conf.MySQL.DbName)
|
||||||
if len(conf.MySQL.DbName) == 0 {
|
if len(conf.MySQL.DbName) == 0 {
|
||||||
conf.MySQL.DbName = "semaphore"
|
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)
|
fmt.Scanln(&conf.SessionDb)
|
||||||
if len(conf.SessionDb) == 0 {
|
if len(conf.SessionDb) == 0 {
|
||||||
conf.SessionDb = "127.0.0.1:6379"
|
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)
|
fmt.Scanln(&conf.TmpPath)
|
||||||
|
|
||||||
if len(conf.TmpPath) == 0 {
|
if len(conf.TmpPath) == 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user