1
votes

I am using Mongooseim 3.2.0 from the source code on the ubuntu server. Below are concern:

  1. What is the best way to run mongooseim as a service so that it automatically restarts if mongooseim crashes or system restarts?
  2. How to interact via terminal with already running mongooseim instance on the ubuntu server like "mongooseimctl live". My guess is running "mongooseimctl live" will try to create another instance. I just want to see the live logs and interaction and don't want to keep scrolling the long log files for this purpose.

I apologize if the answer to above is obvious but just want to follow the best guidance.

1
When I try to use "mongooseimctl live" or "mongooseimctl foreground" in the already running mongooseim instance (in sepaarte terminal on same system), I get the following error: Protocol 'inet_tcp': the name mongooseim@localhost seems to be in use by another Erlang nodeShubham1164
BTW, you probably should not use mongooseim@localhost for a production deployment. Instead, figure out a domain name for you service, get a DNS, and configure the server to [email protected].erszcz
"Protocol 'inet_tcp': the name mongooseim@localhost seems to be in use by another Erlang node", while a bit obscure, says it all. The server is already running in the background - it can't be started the second time in parallel.erszcz

1 Answers

2
votes

mongooseimctl live or mongooseimctl foreground is mostly useful for development or smoke testing a deployment (unless you're running inside a container). For real world use cases you should start the server in the background with mongooseimctl start.

Back to the container - the best approach for containerised applications is to run them in the foreground, therefore in a container startup script use mongooseimctl foreground.

Once the server is running (no matter how it was started) attaching a shell to troubleshoot issues can be done with mongooseimctl debug. This is the command to use when you get the Protocol 'inet_tcp': the name mongooseim@localhost seems to be in use by another Erlang node error. Be careful if it's a production environment - you can easily take the server down with access to this shell.

If you're just interested in watching logs, with no interactive access to the server internals that the shell offers, a simple tail -f /your-configured-mongooseim-log-dir/* should be enough.


Ubuntu nowadays uses systemd for managing its services' lifetimes. A systemd .service file can be found at https://github.com/esl/MongooseIM/blob/master/tools/pkg/platforms/debian_stretch/files/build/mongooseim.service - we use it for packaging into Debian/Ubuntu .deb packages.