ant-media / Ant-Media-Server

Ant Media Server is a live streaming engine software that provides adaptive, ultra low latency streaming by using WebRTC technology with ~0.5 seconds latency. Ant Media Server is auto-scalable and it can run on-premise or on-cloud.
https://antmedia.io
Other
4.27k stars 627 forks source link

Support redis in create_app.sh script #5349

Closed Mohit-3196 closed 6 months ago

Mohit-3196 commented 1 year ago

Created a sample script https://github.com/Mohit-3196/create-app/blob/main/create_app.sh

muratugureminoglu commented 1 year ago

Thanks, @Mohit-3196

It would be better if we make it compatible as follows. There is no need to use separate parameters for username/password and port.

./create_app.sh -n test -c true -r redis://antmedia:antmedia@127.0.0.1:6379

Mohit-3196 commented 1 year ago

Thank you @muratugureminoglu abi for your input. I have made the changes in the script and also updated the readme file. Please let me know if it requires any more changes or if anything is breaking. https://github.com/Mohit-3196/create-app/blob/main/create_app.sh

Thank you

muratugureminoglu commented 1 year ago

Thank you, @Mohit-3196. Please send this as a pull request to our repository so that we can review the changes you made.

Mohit-3196 commented 1 year ago

https://github.com/ant-media/Ant-Media-Server/pull/5412

Mohit-3196 commented 1 year ago

The PR is not passing the CI, please help me with resolving this @muratugureminoglu abi. Thank you

muratugureminoglu commented 1 year ago

Thanks, @Mohit-3196

There is no change in the red5.properties file. Please check the following line.

https://github.com/ant-media/Ant-Media-Server/blob/25fe71a09fccad5eea6c23e2ae22ab7dd671bf85/src/main/server/create_app.sh#L127-L131

Mohit-3196 commented 1 year ago

OK. Thank you @muratugureminoglu

Mohit-3196 commented 1 year ago

I'm still working on the script to finalize it.

FYI Please

muratugureminoglu commented 1 year ago

https://github.com/ant-media/Ant-Media-Server/pull/5461

Mohit-3196 commented 1 year ago

Works fine.

Thank you

Mohit-3196 commented 1 year ago

I made some more detailed tests and below are the results for each case:

  1. Created application from the dashboard

  2. Uploaded the war file from the dashboard

  3. Created application from the terminal

  4. Created application by passing mongoDB credentials from the terminal like: sudo ./create_app.sh -n test03 -m mongo -u username -s password Application test03 is created but it is created locally on the server and I cannot see it on the MongoDB database, instead, the application DB file is created locally.

  5. Created application by using MongoDB without username and password. The application DB file is created locally.

  6. Created application using redis with authentication sudo ./create_app.sh -n test05 redis://default:password@localhost:6379 Application db file is created locally

  7. Created application using redis without authentication sudo ./create_app.sh -n test06 redis@localhost:6379 Application db file is created locally

  1. Uploaded war file from dashboard and db file is created in the database

  2. Created application by passing MongoDB username and password: sudo ./create_app.sh -n test08 -c true -m mongo -u username -s password The application db file is located in the database

  3. Created application using redis with username and password sudo ./create_app.sh -n test12 -c true redis://default:password@localhost:6379 application is created but the db file is available locally

  4. Created application without username and password application is available locally

  1. Creating an application from the web panel: 2023-08-28 10:28:22,431 [https-jsse-nio2-0.0.0.0-5443-exec-7] INFO o.r.s.a.MultiThreadedApplicationAdapter - Running create app script, war file name (null if default): null, app name: test17 2023-08-28 10:28:22,448 [https-jsse-nio2-0.0.0.0-5443-exec-7] INFO i.antmedia.console.AdminApplication - Creating application with command: /bin/bash create_app.sh -n test17 -w true -p /usr/local/antmedia -c true -m redis://default:password@localhost:6379 -u -s 2023-08-28 10:28:23,841 [vert.x-worker-thread-1] INFO org.red5.server.tomcat.WarDeployer - Deploy wars with app start 2023-08-28 10:28:24,209 [vert.x-worker-thread-1] INFO org.red5.server.tomcat.TomcatLoader - Starting Tomcat - Web application 2023-08-28 10:28:24,209 [vert.x-worker-thread-1] INFO org.red5.server.tomcat.TomcatLoader - Application root: /usr/local/antmedia/webapps 2023-08-28 10:28:24,221 [vert.x-worker-thread-1] INFO o.a.catalina.loader.WebappLoader - Unknown loader jdk.internal.loader.ClassLoaders$AppClassLoader@6a6824be class jdk.internal.loader.ClassLoaders$AppClassLoader 2023-08-28 10:28:24,233 [vert.x-worker-thread-1] INFO o.a.c.c.C.[.[0.0.0.0].[/test17] - No Spring WebApplicationInitializer types detected on classpath 2023-08-28 10:28:24,236 [vert.x-worker-thread-1] INFO ROOT - Starting up context: test17 2023-08-28 10:28:24,331 [vert.x-worker-thread-1] ERROR o.g.j.s.s.SpringComponentProvider - Spring context lookup failed, skipping spring component provider initialization. 2023-08-28 10:28:24,485 [Launcher:/test17] INFO org.red5.server.Context - Deployment type: bootstrap 2023-08-28 10:28:24,487 [Launcher:/test17] INFO io.antmedia.datastore.db.MongoStore - uri:mongodb://redis://default:mohit@localhost:6379 2023-08-28 10:28:24,488 [Launcher:/test17] WARN o.s.w.c.s.XmlWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'web.scope' defined in ServletContext resource [/WEB-INF/red5-web.xml]: Cannot resolve reference to bean 'web.handler' while setting bean property 'handler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'web.handler' defined in ServletContext resource [/WEB-INF/red5-web.xml]: Cannot resolve reference to bean 'dataStoreFactory' while setting bean property 'dataStoreFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataStoreFactory' defined in ServletContext resource [/WEB-INF/red5-web.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: The connection string contains an invalid host 'redis:'. The port '' is not a valid, it must be an integer between 0 and 65535 When creating an application using -c true flag for the cluster, even when MongoDB credentials are not passed, there's no warning message.
muratugureminoglu commented 1 year ago

When I checked it 's working if you add -h parameter as follows.

sudo ./create_app.sh -n test12 -c true -h redis://default:password@localhost:6379
Mohit-3196 commented 1 year ago

Yes, it's fine abi. Thank you for your help.

There's a new issue that I see and here's how to reproduce it:

  1. Run as a cluster with the redis database.
  2. Try creating an application from the panel

Result The application is not created and it gets stuck in the creating state.

Error logs: 2023-09-11 06:39:55,766 [https-jsse-nio2-0.0.0.0-5443-exec-9] INFO i.antmedia.console.AdminApplication - Creating application with command: /bin/bash create_app.sh -n test01 -w true -p /usr/local/antmedia -c true -m redis://default:mohit@localhost:6379 -u -s 2023-09-11 06:39:57,140 [vert.x-worker-thread-7] INFO org.red5.server.tomcat.WarDeployer - Deploy wars with app start 2023-09-11 06:39:57,526 [vert.x-worker-thread-7] INFO org.red5.server.tomcat.TomcatLoader - Starting Tomcat - Web application 2023-09-11 06:39:57,526 [vert.x-worker-thread-7] INFO org.red5.server.tomcat.TomcatLoader - Application root: /usr/local/antmedia/webapps 2023-09-11 06:39:57,539 [vert.x-worker-thread-7] INFO o.a.catalina.loader.WebappLoader - Unknown loader jdk.internal.loader.ClassLoaders$AppClassLoader@6a6824be class jdk.internal.loader.ClassLoaders$AppClassLoader 2023-09-11 06:39:57,552 [vert.x-worker-thread-7] INFO o.a.c.c.C.[.[0.0.0.0].[/test01] - No Spring WebApplicationInitializer types detected on classpath 2023-09-11 06:39:57,555 [vert.x-worker-thread-7] INFO ROOT - Starting up context: test01 2023-09-11 06:39:57,664 [vert.x-worker-thread-7] ERROR o.g.j.s.s.SpringComponentProvider - Spring context lookup failed, skipping spring component provider initialization. 2023-09-11 06:39:57,852 [Launcher:/test01] INFO org.red5.server.Context - Deployment type: bootstrap 2023-09-11 06:39:57,857 [Launcher:/test01] INFO io.antmedia.datastore.db.MongoStore - uri:mongodb://redis://default:mohit@localhost:6379 2023-09-11 06:39:57,860 [Launcher:/test01] WARN o.s.w.c.s.XmlWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'web.scope' defined in ServletContext resource [/WEB-INF/red5-web.xml]: Cannot resolve reference to bean 'web.handler' while setting bean property 'handler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'web.handler' defined in ServletContext resource [/WEB-INF/red5-web.xml]: Cannot resolve reference to bean 'dataStoreFactory' while setting bean property 'dataStoreFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataStoreFactory' defined in ServletContext resource [/WEB-INF/red5-web.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: The connection string contains an invalid host 'redis:'. The port '' is not a valid, it must be an integer between 0 and 65535