sipcapture / homer-app

HOMER 7.x Front-End and API Server
http://sipcapture.io
GNU Affero General Public License v3.0
207 stars 85 forks source link

Server Cannot be started #531

Closed Gilbert2015 closed 1 year ago

Gilbert2015 commented 1 year ago

Upon attempting to deploy the Homer 7 application using the Docker image (sipcapture/webapp:latest), the configuration process completed successfully. However, when attempting to start the server, an error message was encountered. The error message is as follows:

Pre-Flight provisioning completed!  CONNECT to DB ROOT STRING: [host=devperconacluster.development.svc.cluster.local user=postgres dbname=postgres sslmode=disable port=5432 password=]  {"level":"info","msg":"init logging system","time":"2023-07-10T19:31:44Z"}  HOMER - create db [homer_config] with [name=postgres] 

(/homer-app/migration/migration.go:85) [2023-07-10 19:31:44]  pq: database "homer_config" already exists 

(/homer-app/migration/migration.go:85) [2023-07-10 19:31:44] [1.15ms] CREATE DATABASE homer_config OWNER postgres
[0 rows affected or returned ]  DONE   HOMER - show users  Role name | Attributes

homer_user  |       
pgbouncer   |       
pguser  |       
postgres    |   superuser, create database  
primaryuser |       

 DONE  {"level":"info","msg":"init logging system","time":"2023-07-10T19:31:44Z"}  CONNECT to DB ROOT STRING: [host=devperconacluster.development.svc.cluster.local user=postgres dbname=postgres sslmode=disable port=5432 password=LFjcErEEFxKIoxACytbW9Nol]   HOMER - create db [homer_data] with [name=postgres] 

(/homer-app/migration/migration.go:85) [2023-07-10 19:31:44]  pq: database "homer_data" already exists 

(/homer-app/migration/migration.go:85) [2023-07-10 19:31:44] [1.16ms] CREATE DATABASE homer_data OWNER postgres
[0 rows affected or returned ]  DONE   HOMER - show users  Role name | Attributes

homer_user  |       
pgbouncer   |       
pguser  |       
postgres    |   superuser, create database  
primaryuser |       

 DONE  {"level":"info","msg":"init logging system","time":"2023-07-10T19:31:44Z"}  HOMER - creating tables for the config DB [dbname=homer_config]   DONE  {"level":"info","msg":"init logging system","time":"2023-07-10T19:31:45Z"}  HOMER - filling tables for the config DB [dbname=homer_config]   DONE  time="2023-07-10T19:31:45Z" level=info msg="SELECT * FROM \"versions\" " module=gorm type=sql Database provisioning completed! {"level":"info","msg":"init logging system","time":"2023-07-10T19:31:45Z"} Successful ping: devperconacluster.development.svc.cluster.local, Type: data, Node: LocalNode PostgreSQL version: 14.7  time="2023-07-10T19:31:46Z" level=info msg="INSERT INTO \"applications\" (\"guid\",\"name\",\"host\",\"version\",\"created_at\") VALUES ($1,$2,$3,$4,$5) ON CONFLICT (name,host) DO UPDATE SET version = EXCLUDED.version, guid = EXCLUDED.guid RETURNING \"applications\".\"id\"" module=gorm type=sql 


    /__/\             
    \  \:\           
     \__\:\  
 ___ /  /::\     
/__/\  /:/\:\     _____     
\  \:\/:/__\/    |___  |    
 \  \::/            / /   
  \  \:\           / /             
   \  \:\         /_/               
    \__\/         

  Version: homer-app 1.4.59.  {"time":"2023-07-10T19:31:46.087296323Z","level":"FATAL","prefix":"echo","file":"main.go","line":"882","message":"Couldn't start server"}

github-actions[bot] commented 1 year ago

Your report is appreciated. Please star this repository to motivate its developers! :star:

lmangani commented 1 year ago

Are you using one of our docker-compose examples? Homer is not a single container application.

Gilbert2015 commented 1 year ago

Indeed, I have structured my Docker image deployment according to the examples provided in the docker-compose repository. Since my intention is to deploy the applications on an Openshift Kubernetes cluster, I have created a separate Dockerfile for each application.

lmangani commented 1 year ago

Got it. Then you must have converted something wrong since the bundle works and its quite simple. Agents send to heplify-server, which writes to the database. The Homer-app reads from database. That's about it.

Sadly, there are literally HUNDREDS of homer users running on k8s but none of the users ever shared their config back with the community.... magic of one-way opensource, I guess.

Gilbert2015 commented 1 year ago

Thank you for your response and explanation. I wanted to discuss an error message I encountered in my code. The error message looks like this:

{"time":"2023-07-10T19:31:46.087296323Z","level":"FATAL","prefix":"echo","file":"main.go","line":"882","message":"Couldn't start server"}

Upon investigating, I found that the error originates from the main.go file at line 882, which contains the following code snippet:

if httpEnable {
    /* need excute it in background because HTTP locks */
    httpHost := viper.GetString("http_settings.host")
    httpPort := viper.GetString("http_settings.port")
    httpURL := fmt.Sprintf("%s:%s", httpHost, httpPort)

    if viper.GetBool("https_settings.enable") {
        go func(url string) {
            e.Logger.Fatal(e.Start(url))
        }(httpURL)
    } else {
        err := e.Start(httpURL)
        if err != nil {
            logger.Error(err.Error())
            e.Logger.Fatal("Couldn't start server")
        }
    }
}

The error is related to the http_settings configuration in the webconfig file, which looks like this:

"http_settings": {
    "host": "0.0.0.0",
    "port": homer_web_port,
    "root": "/usr/local/homer/dist",
    "path": "homer_serve_path",
    "gzip": true,
    "debug": false
}

Interestingly, removing the line "port": homer_web_port, from the http_settings configuration resolved the error. However, I'm unsure if this change impacts the functionality of the heplify-server. If I still want to utilize the http_settings, how can I resolve the issue?

I appreciate your assistance in clarifying the consequences of removing that line and suggesting a solution to the problem while still being able to utilize the http_settings configuration.

Gilbert2015 commented 1 year ago

Hi, I was able to resolve the issue by changing the port from 80 to 8080