dorel14 / 3CX-Cdr-Tcp-Server

GNU General Public License v3.0
4 stars 3 forks source link

Issue when archiving files #31

Closed MrGlenn-tech closed 1 month ago

MrGlenn-tech commented 1 month ago

Hi,

now i got everything working and i can se one line in the database but then it stops wokring. and the docker image restarts.

this is the error i get any idea how i should solve it?

`r_FR
     historyid                  callid  ... final_dispname missed_queue_calls
0  Call 282060  90df08df8f010000_20028  ...     Backup no2                NaN

[1 rows x 27 columns]
{"historyid":"Call 282060","callid":"90df08df8f010000_20028","duration":"00:00:03","time_start":1717441051000,"time_answered":1717441066000,"time_end":1717441070000,"reason_terminated":"TerminatedByDst","from_no":"076XXXXXXXX","to_no":"Ext.80042","from_dn":"10020","to_dn":"80042","dial_no":"80042","reason_changed":"ReplacedDst","final_number":"Ext.10016","final_dn":"10016","bill_code":null,"bill_rate":null,"bill_cost":null,"bill_name":null,"chain":"Chain: 076XXXXXX;Ext.80042;Ext.10016;","from_type":"Line","to_type":"Queue","final_type":"Extension","from_dispname":"P100 - 20240522","to_dispname":"Balder - Hisslarm","final_dispname":"Backup no2","missed_queue_calls":null}

{"cdr_historyid":"Call 282060","abandonned":false,"handling_time_seconds":4,"waiting_time_seconds":15,"call_date":1717372800000,"call_time":"16:57:31","call_week":23,"day_of_week":"lundi","filename":"cdr-240603165731.282060.log"}

Starting new HTTP connection (1): webapi:8000
http://webapi:8000 "GET /api/v1/cdr/historyid/Call%20282060 HTTP/1.1" 200 709
Starting new HTTP connection (1): webapi:8000
http://webapi:8000 "GET /api/v1/cdrdetails/historyid/Call%20282060 HTTP/1.1" 200 235
200
200
cdr existant
cdr detail existant
cdr existant
cdr detail existant
Line1: Call 282060,90df08df8f010000_20028,00:00:03,2024/06/03 16:57:31,2024/06/03 16:57:46,2024/06/03 16:57:50,TerminatedByDst,076XXXXX,Ext.80042,10020,80042,80042,ReplacedDst,Ext.10016,10016,,,,,Chain: 076XXXXXX;Ext.80042;Ext.10016;,Line,Queue,Extension,P100 - 20240522,Balder - Hisslarm,Backup no2,
Line2:
cdr-240603165731.282060.log
Permissions of the directory:/home/appuser/cdrfiles/cdrfiles_archives/
Read permission: Yes
Write permission: Yes
Execute permission: Yes
[chan 1] EOF sent (1)
Traceback (most recent call last):
  File "/home/appuser/app/srv/runserver.py", line 51, in <module>
    scpc.monitor(os.environ.get('SCP_3CX_SRVDIR'),
  File "/home/appuser/app/myhelpers/scpclient.py", line 39, in monitor
    csv_files_read(localfolder, archivefolder)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/appuser/app/myhelpers/traitement_fichier.py", line 62, in csv_files_read
    files_move(f, archivefolder)
  File "/home/appuser/app/myhelpers/traitement_fichier.py", line 31, in files_move
    os.mkdir(savefolderd, mode=0o777, exist_ok=False)
TypeError: 'exist_ok' is an invalid keyword argument for mkdir()`
MrGlenn-tech commented 1 month ago

Did some more testsing / some changes and it seems like this where it stops working PermissionError: [Errno 13] Permission denied: '/home/appuser/cdrfiles/cdrfiles_archives/2024' Im running the docker-compose as sudo not sure if any thing need to change on my side

dorel14 commented 1 month ago

Hello I know there still issues but i need specific issue per bugs , that's why i close preceding one

For this one , i see in logs what happens , it is linked with the permission issue I have made some improvements to test permissions and create folders that not exist to archive files and in this improvement i did not use the function correctly

dorel14 commented 1 month ago

Another i can see is that in your .env file the locales is not good , you let LOCALE_LANGUAGE =fr_FR
Letting this , your times will not be well formatted and the day_of_week will be set in french

dorel14 commented 1 month ago

Just for information ,i think the docker image doesn't restart , it's just the poller that scans scp that run every 60s

dorel14 commented 1 month ago

Can we close this now ?

MrGlenn-tech commented 1 month ago

Sorry to bother you,

Was this fixed ? i get the same issue unfurtuntly

dorel14 commented 1 month ago

Ok , can you send me latest logs ?

MrGlenn-tech commented 1 month ago

Hi,

Sure here they are

cdr-240607075205.283879.log Permissions of the directory:/home/appuser/cdrfiles/cdrfiles_archives/ Read permission: Yes Write permission: Yes Execute permission: Yes Traceback (most recent call last): File "/home/appuser/app/srv/runserver.py", line 51, in <module> scpc.monitor(os.environ.get('SCP_3CX_SRVDIR'), File "/home/appuser/app/myhelpers/scpclient.py", line 39, in monitor csv_files_read(localfolder, archivefolder) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/appuser/app/myhelpers/traitement_fichier.py", line 63, in csv_files_read files_move(f, archivefolder) File "/home/appuser/app/myhelpers/traitement_fichier.py", line 32, in files_move os.mkdir(savefolderd, mode=0o777) PermissionError: [Errno 13] Permission denied: '/home/appuser/cdrfiles/cdrfiles_archives/2024'

dorel14 commented 1 month ago

Thx Can you try adding thé user you run docker to thé docker group si that you don't have to run docker compose with sudo ?

MrGlenn-tech commented 1 month ago

Yes did that just now and did a docker-compose up with out sudo and it starts but the same issue in the log files

dorel14 commented 1 month ago

Normaly , if you user IS part of docker group, no need if sudo

MrGlenn-tech commented 1 month ago

It starts now with out sudo so that part is ok, but i still get the same error code in the log file about permission.

dorel14 commented 1 month ago

Great , 1- can you look at thé user and permission for the folder creating thé error 2 - Can you remove folder 2024

dorel14 commented 1 month ago

Today , i was able to reproduce the problem , perhaps i will have a solution tomorow

dorel14 commented 1 month ago

Hello , i published latest master this evening , i hope it will now be ok

MrGlenn-tech commented 1 month ago

Tested it now,

Getting a new error now :(

/home/appuser/app Traceback (most recent call last): File "/home/appuser/app/srv/runserver.py", line 62, in <module> run_server(server_type, client_config) File "/home/appuser/app/srv/runserver.py", line 53, in run_server with create_client(server_type, **client_config) as client: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/appuser/app/srv/runserver.py", line 41, in create_client return scpclient(**kwargs) ^^^^^^^^^^^^^^^^^^^ TypeError: scpclient.__init__() got an unexpected keyword argument 'server_dir'

dorel14 commented 1 month ago

Sorry , i've made some change in code so that it will be easier to maintain

new master correct this error

MrGlenn-tech commented 1 month ago

Now it works ! Great job indeed ! that is so good, i will buy you some more beers for sure :)

dorel14 commented 1 month ago

Great Thx for the beers Don't hesitate to create improvements issue if needed