initAbout initializes the app's /about API endpoint with the app and system info.
(q *models.Queries, db *sqlx.DB)
| 882 | |
| 883 | // initAbout initializes the app's /about API endpoint with the app and system info. |
| 884 | func initAbout(q *models.Queries, db *sqlx.DB) about { |
| 885 | var ( |
| 886 | mem runtime.MemStats |
| 887 | ) |
| 888 | |
| 889 | // Memory / alloc stats. |
| 890 | runtime.ReadMemStats(&mem) |
| 891 | |
| 892 | info := types.JSONText(`{}`) |
| 893 | if err := db.QueryRow(q.GetDBInfo).Scan(&info); err != nil { |
| 894 | lo.Printf("WARNING: error getting database version: %v", err) |
| 895 | } |
| 896 | |
| 897 | hostname, err := os.Hostname() |
| 898 | if err != nil { |
| 899 | lo.Printf("WARNING: error getting hostname: %v", err) |
| 900 | } |
| 901 | |
| 902 | return about{ |
| 903 | Version: versionString, |
| 904 | Build: buildString, |
| 905 | GoArch: runtime.GOARCH, |
| 906 | GoVersion: runtime.Version(), |
| 907 | Database: info, |
| 908 | System: aboutSystem{ |
| 909 | NumCPU: runtime.NumCPU(), |
| 910 | }, |
| 911 | Host: aboutHost{ |
| 912 | OS: runtime.GOOS, |
| 913 | Machine: runtime.GOARCH, |
| 914 | Hostname: hostname, |
| 915 | }, |
| 916 | } |
| 917 | |
| 918 | } |
| 919 | |
| 920 | // initHTTPServer sets up and runs the app's main HTTP server and blocks forever. |
| 921 | func initHTTPServer(cfg *Config, urlCfg *UrlConfig, i *i18n.I18n, fs stuffbin.FileSystem, app *App) *echo.Echo { |