1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- // Package kurzd contains the Kurz daemon command.
- package main
- import (
- "github.com/spf13/viper"
- "os"
- "time"
- "database/sql"
- _ "github.com/go-sql-driver/mysql"
- )
- /**
- kurzd
- -v Verbose (default: false).
- help Display help.
- server Serve kurz (default option).
- -p|--port <port_id> Serve on this IP port (default: 80).
- -m|--monitoring <port_id> Serve monitoring on this IP port (default: none)
- install Install kurzd completely.
- config Install the configuration define by command line to ~.
- schema Install the kurz database schema.
- export Export kurzd data.
- -o <file> Specify a destination file.
- config Export kurz configuration.
- content Export kurz content.
- uninstall Uninstall kurzd completely.
- config Uninstall the curz configuration file from ~.
- schema Uninstall the curz database schema.
- status Report on kurzd status
- stop Stop all instances of kurzd on the current server (restricted)
- */
- func main() {
- Execute()
- os.Exit(0)
- }
- type MapEntry struct {
- Hash uint64
- Url string
- Date1, Date2, Date3 time.Time
- RefCount uint32
- }
- func dbDial(dbDriver, dbDsn string) (*sql.DB, error) {
- db, err := sql.Open(dbDriver, dbDsn)
- if err != nil {
- return nil, err
- }
- return db, nil
- }
- func parseDbCred() (driver, dsn string) {
- viper.SetDefault("database.driver", "mysql")
- viper.SetDefault("database.dsn", "root:root@tcp(localhost:3306)/kurz")
- driver = viper.Get("database.driver").(string)
- dsn = viper.Get("database.dsn").(string)
- dsn += "?parseTime=true"
- return
- }
|