djangopbx / djangopbx-install.sh

DjangoPBX - Installer for the full-featured domain based multi-tenant PBX driven by Django and FreeSwitch.
MIT License
5 stars 9 forks source link

New installation, freeswitch does not start. #3

Closed wouam31200 closed 9 months ago

wouam31200 commented 9 months ago

Hi Adrian,

I just did a fresh install. I have freeswitch which does not start, during installation I selected in install.sh: pkg with the token.

root@djangopbx:~# systemctl restart freeswitch
Job for freeswitch.service failed because the control process exited with error code.
See "systemctl status freeswitch.service" and "journalctl -xeu freeswitch.service" for details.
root@djangopbx:~# systemctl reload freeswitch
Failed to reload freeswitch.service: Job type reload is not applicable for unit freeswitch.service.
root@djangopbx:~# systemctl status freeswitch.service
× freeswitch.service - freeswitch
     Loaded: loaded (/lib/systemd/system/freeswitch.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Wed 2024-01-17 14:15:13 CET; 43s ago
    Process: 2287 ExecStartPre=/bin/mkdir -p /var/run/freeswitch/ (code=exited, status=0/SUCCESS)
    Process: 2288 ExecStartPre=/bin/chown -R ${USER}:${GROUP} /var/lib/freeswitch /var/log/freeswitch /home/dj>
        CPU: 13ms

janv. 17 14:15:13 djangopbx systemd[1]: freeswitch.service: Scheduled restart job, restart counter is at 5.
janv. 17 14:15:13 djangopbx systemd[1]: Stopped freeswitch.service - freeswitch.
janv. 17 14:15:13 djangopbx systemd[1]: freeswitch.service: Start request repeated too quickly.
janv. 17 14:15:13 djangopbx systemd[1]: freeswitch.service: Failed with result 'exit-code'.
janv. 17 14:15:13 djangopbx systemd[1]: Failed to start freeswitch.service - freeswitch.
root@djangopbx:~# 
AdrianFretwell commented 9 months ago

Hi there, Interesting, I did two installs yesterday evening using the Signalwire token, they both worked OK. It must be something fundamental to prevent FreeSWITCH from starting. Is there anything useful in /var/log/freeswitch/freeswitch.log?

Did all the settings like default and SIP profiles load OK? Cheers, Adrian.

AdrianFretwell commented 9 months ago

I notice this appears to be from a restart command (systemctl restart freeswitch).

What do you see with a systemctl stop freeswitch and then a systemctl start freeswitch

wouam31200 commented 9 months ago

So far I haven't made any changes. I wanted to see what it looks like...

root@djangopbx:/var/log# systemctl stop freeswitch
root@djangopbx:/var/log# systemctl start freeswitch
Job for freeswitch.service failed because the control process exited with error code.
See "systemctl status freeswitch.service" and "journalctl -xeu freeswitch.service" for details.
root@djangopbx:/var/log#

in the logs, I don't have freeswitch.

root@djangopbx:/var/log# ls
alternatives.log  debug       kern.log    README    vmware-network.1.log     vmware-vmtoolsd-root.log
apt       django-pbx  lastlog     runit     vmware-network.log       wtmp
auth.log      dpkg.log    messages    syslog    vmware-vmsvc-root.1.log
btmp          faillog     nginx   sysstat   vmware-vmsvc-root.2.log
cron.log      installer   postgresql  user.log  vmware-vmsvc-root.3.log
daemon.log    journal     private     uwsgi     vmware-vmsvc-root.log
root@djangopbx:/var/log#
root@djangopbx:/var/log# systemctl status freeswitch.service
× freeswitch.service - freeswitch
     Loaded: loaded (/lib/systemd/system/freeswitch.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Wed 2024-01-17 15:15:33 CET; 3min 3s ago
    Process: 2779 ExecStartPre=/bin/mkdir -p /var/run/freeswitch/ (code=exited, status=0/SUCCESS)
    Process: 2780 ExecStartPre=/bin/chown -R ${USER}:${GROUP} /var/lib/freeswitch /var/log/freeswitch /home/dj>
        CPU: 13ms

janv. 17 15:15:33 djangopbx systemd[1]: freeswitch.service: Scheduled restart job, restart counter is at 5.
janv. 17 15:15:33 djangopbx systemd[1]: Stopped freeswitch.service - freeswitch.
janv. 17 15:15:33 djangopbx systemd[1]: freeswitch.service: Start request repeated too quickly.
janv. 17 15:15:33 djangopbx systemd[1]: freeswitch.service: Failed with result 'exit-code'.
janv. 17 15:15:33 djangopbx systemd[1]: Failed to start freeswitch.service - freeswitch.

journalctl -xeu freeswitch.service:

Defined-By: systemd
░░ Support: https://www.debian.org/support
░░ 
░░ Le redémarrage automatique de l'unité (unit) freeswitch.service a été planifié, en
░░ raison de sa configuration avec le paramètre Restart=.
janv. 17 15:15:33 djangopbx systemd[1]: Stopped freeswitch.service - freeswitch.
░░ Subject: L'unité (unit) freeswitch.service a terminé son arrêt
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░ 
░░ L'unité (unit) freeswitch.service a terminé son arrêt.
janv. 17 15:15:33 djangopbx systemd[1]: Starting freeswitch.service - freeswitch...
░░ Subject: L'unité (unit) freeswitch.service a commencé à démarrer
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░ 
░░ L'unité (unit) freeswitch.service a commencé à démarrer.
janv. 17 15:15:33 djangopbx chown[2780]: /bin/chown: impossible d'accéder à '/var/log/freeswitch': Aucun fichi>
janv. 17 15:15:33 djangopbx systemd[1]: freeswitch.service: Control process exited, code=exited, status=1/FAIL>
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░ 
░░ An ExecStartPre= process belonging to unit freeswitch.service has exited.
░░ 
░░ The process' exit code is 'exited' and its exit status is 1.
janv. 17 15:15:33 djangopbx systemd[1]: freeswitch.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░ 
░░ The unit freeswitch.service has entered the 'failed' state with result 'exit-code'.
janv. 17 15:15:33 djangopbx systemd[1]: Failed to start freeswitch.service - freeswitch.
░░ Subject: L'unité (unit) freeswitch.service a échoué
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░ 
░░ L'unité (unit) freeswitch.service a échoué, avec le résultat failed.
janv. 17 15:15:33 djangopbx systemd[1]: freeswitch.service: Scheduled restart job, restart counter is at 5.
░░ Subject: Le redémarrage automatique d'une unité (unit) a été planifié
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░ 
░░ Le redémarrage automatique de l'unité (unit) freeswitch.service a été planifié, en
░░ raison de sa configuration avec le paramètre Restart=.
janv. 17 15:15:33 djangopbx systemd[1]: Stopped freeswitch.service - freeswitch.
░░ Subject: L'unité (unit) freeswitch.service a terminé son arrêt
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░ 
░░ L'unité (unit) freeswitch.service a terminé son arrêt.
janv. 17 15:15:33 djangopbx systemd[1]: freeswitch.service: Start request repeated too quickly.
janv. 17 15:15:33 djangopbx systemd[1]: freeswitch.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░ 
░░ The unit freeswitch.service has entered the 'failed' state with result 'exit-code'.
janv. 17 15:15:33 djangopbx systemd[1]: Failed to start freeswitch.service - freeswitch.
░░ Subject: L'unité (unit) freeswitch.service a échoué
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░ 
░░ L'unité (unit) freeswitch.service a échoué, avec le résultat failed.
wouam31200 commented 9 months ago

Apparently the freeswitch repository was not created correctly because it is not signed

root@djangopbx:/usr/src/djangopbx-install# apt-get update
Atteint :1 http://deb.debian.org/debian bookworm InRelease
Réception de :2 http://deb.debian.org/debian bookworm-updates InRelease [52,1 kB]                             
Réception de :3 http://security.debian.org/debian-security bookworm-security InRelease [48,0 kB]              
Err :4 https://freeswitch.signalwire.com/repo/deb/debian-release bookworm InRelease                           
  401  Unauthorized [IP : 190.102.98.174 443]
Lecture des listes de paquets... Fait
E: Impossible de récupérer https://freeswitch.signalwire.com/repo/deb/debian-release/dists/bookworm/InRelease  401  Unauthorized [IP : 190.102.98.174 443]
E: Le dépôt https://freeswitch.signalwire.com/repo/deb/debian-release bookworm InRelease n'est pas signé.
N: Les mises à jour depuis un tel dépôt ne peuvent s'effectuer de manière sécurisée, et sont donc désactivées par défaut.
N: Voir les pages de manuel d'apt-secure(8) pour la création des dépôts et les détails de configuration d'un utilisateur.
AdrianFretwell commented 9 months ago

I see. If I execute an apt-get update, the Signalwire repository looks OK. See below:

root@djangopbx-test5:~# apt-get update Get:1 http://security.debian.org/debian-security bookworm-security InRelease [48.0 kB] Hit:2 http://ftp.uk.debian.org/debian bookworm InRelease
Get:3 http://ftp.uk.debian.org/debian bookworm-updates InRelease [52.1 kB]
Get:4 http://security.debian.org/debian-security bookworm-security/main Sources [72.9 kB]
Get:5 http://security.debian.org/debian-security bookworm-security/main amd64 Packages [134 kB] Get:6 http://security.debian.org/debian-security bookworm-security/main Translation-en [80.0 kB] Hit:7 https://freeswitch.signalwire.com/repo/deb/debian-release bookworm InRelease
Fetched 387 kB in 1s (462 kB/s) Reading package lists... Done

I'm wondering if the problem starting FreeSWITCH is because FreeSWITCH has not been installed at all? The chown error is suggesting that one or more of the directories are missing.

Could there be a problem with your Signalwire Token?

wouam31200 commented 9 months ago

It's definitely a token problem on my side. Sorry...

I just did a new installation, following the reboot, nginx does not start.

Thankyou for using DjangoPBX

root@djangopbx:/usr/src/djangopbx-install# reboot
root@djangopbx:/usr/src/djangopbx-install# Connection to 10.0.0.34 closed by remote host.
Connection to 10.0.0.34 closed.
lilianherrera@MBP-de-Lilian-2 ~ % ssh root@10.0.0.34
root@10.0.0.34's password: 
Linux djangopbx 6.1.0-17-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.69-1 (2023-12-30) x86_64

**************************************************************************
*                                                                        *
*                            djangopbx.com                               *
*                                                                        *
*                               WARNING:                                 *
*                                                                        *
* You have accessed the host djangopbx system operated by:               *
* My Company. You are required  to have personal authorisation           *
* from the system administrator before you use this computer and you are *
* strictly limited to  the  use set  out  in that written authorisation. *
* Unauthorised access or use of this system is prohibited and            *
* constitutes an offence under the Computer Misuse Act 1990.             *
*                                                                        *
* If you are NOT authorised to use this computer DISCONNECT NOW!         *
*                                                                        *
**************************************************************************

Last login: Wed Jan 17 16:05:03 2024
root@djangopbx:~# systemctl status nginx
× nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Wed 2024-01-17 16:40:37 CET; 38s ago
       Docs: man:nginx(8)
    Process: 646 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)
        CPU: 40ms

janv. 17 16:40:35 djangopbx systemd[1]: Starting nginx.service - A high performance web server and a reverse proxy s>
janv. 17 16:40:37 djangopbx nginx[646]: nginx: [emerg] bind() to 10.0.0.34:80 failed (99: Cannot assign requested ad>
janv. 17 16:40:37 djangopbx nginx[646]: nginx: configuration file /etc/nginx/nginx.conf test failed
janv. 17 16:40:37 djangopbx systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
janv. 17 16:40:37 djangopbx systemd[1]: nginx.service: Failed with result 'exit-code'.
janv. 17 16:40:37 djangopbx systemd[1]: Failed to start nginx.service - A high performance web server and a reverse >
root@djangopbx:~# systemctl start nginx
root@djangopbx:~# systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; preset: enabled)
     Active: active (running) since Wed 2024-01-17 16:43:34 CET; 3s ago
       Docs: man:nginx(8)
    Process: 1119 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
    Process: 1120 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
   Main PID: 1121 (nginx)
      Tasks: 3 (limit: 2315)
     Memory: 2.7M
        CPU: 37ms
     CGroup: /system.slice/nginx.service
             ├─1121 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;"
             ├─1122 "nginx: worker process"
             └─1123 "nginx: worker process"

janv. 17 16:43:34 djangopbx systemd[1]: Starting nginx.service - A high performance web server and a reverse proxy s>
janv. 17 16:43:34 djangopbx systemd[1]: Started nginx.service - A high performance web server and a reverse proxy se>
root@djangopbx:~# 
AdrianFretwell commented 9 months ago

Hi, It looks like nginx is having an issue binding to the address/port. (10.0.0.34:80 failed (99: Cannot assign requested address)

The install script tries to work out your default IP address and set it in the site config file /etc/nginx/sites-available/djangopbx

Based on your ssh command (ssh root@10.0.0.34) I would say that the IP address written to the nginx config file is correct, so my guess is that it is having difficulty with binding to port 80. Do you have anything else using port 80?

Cheers, Adrian.

wouam31200 commented 9 months ago

HI, I don't have anything that uses port 80. It's just a VM dedicated to DjangoPBX

Each time the VM is rebooted, nginx does not start correctly. By restarting nginx, no more problems.

Last login: Wed Jan 17 16:41:03 2024 from 10.0.0.66
root@djangopbx:~# systemctl status nginx
× nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Wed 2024-01-17 17:12:42 CET; 20s ago
       Docs: man:nginx(8)
    Process: 645 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)
        CPU: 46ms

janv. 17 17:12:40 djangopbx systemd[1]: Starting nginx.service - A high performance web server and a reverse proxy s>
janv. 17 17:12:42 djangopbx nginx[645]: nginx: [emerg] bind() to 10.0.0.34:80 failed (99: Cannot assign requested ad>
janv. 17 17:12:42 djangopbx nginx[645]: nginx: configuration file /etc/nginx/nginx.conf test failed
janv. 17 17:12:42 djangopbx systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
janv. 17 17:12:42 djangopbx systemd[1]: nginx.service: Failed with result 'exit-code'.
janv. 17 17:12:42 djangopbx systemd[1]: Failed to start nginx.service - A high performance web server and a reverse >
root@djangopbx:~# systemctl stop nginx
root@djangopbx:~# systemctl start nginx
root@djangopbx:~# systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; preset: enabled)
     Active: active (running) since Wed 2024-01-17 17:13:21 CET; 3s ago
       Docs: man:nginx(8)
    Process: 1108 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
    Process: 1109 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
   Main PID: 1110 (nginx)
      Tasks: 3 (limit: 2315)
     Memory: 2.7M
        CPU: 35ms
     CGroup: /system.slice/nginx.service
             ├─1110 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;"
             ├─1111 "nginx: worker process"
             └─1112 "nginx: worker process"

janv. 17 17:13:21 djangopbx systemd[1]: Starting nginx.service - A high performance web server and a reverse proxy s>
janv. 17 17:13:21 djangopbx systemd[1]: Started nginx.service - A high performance web server and a reverse proxy se>
root@djangopbx:~#
AdrianFretwell commented 9 months ago

Thankyou this is interesting and valuable feedback.

I am aware there have been reports of nginx trying to start before the network layer is ready. This may be the issue in your case. For systemd, this is resolved by adding a "wants" declaration to the nginx unit file, but I have checked and /usr/lib/systemd/system/nginx.service looks OK on the installs that I have inspected (unit file attached below).

(Assuming you are using systemd) If your unit file already has the "Wants" line, you could try further delaying the start of nginx by adding: ExecStartPre=/bin/sleep 10 just below the PID declaration.

Let me know how it goes...

[Unit] Description=A high performance web server and a reverse proxy server Documentation=man:nginx(8) After=network-online.target remote-fs.target nss-lookup.target Wants=network-online.target

[Service] Type=forking PIDFile=/run/nginx.pid ExecStartPre=/usr/sbin/nginx -t -q -g 'daemon on; master_process on;' ExecStart=/usr/sbin/nginx -g 'daemon on; master_process on;' ExecReload=/usr/sbin/nginx -g 'daemon on; master_process on;' -s reload ExecStop=-/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid TimeoutStopSec=5 KillMode=mixed

[Install] WantedBy=multi-user.target

wouam31200 commented 9 months ago

Hi, I added: ExecStartPre=/bin/sleep 10 It works very well ! I thank you