Hi,
We have two Tryton servers. One of them automatically compiles py-files after they are changed on this server. On the second server, py-files are not compiled, but we can see these messages:
INFO:werkzeug: * Detected change in '.../file.py', reloading
INFO:werkzeug: * Restarting with stat
What does automatic compilation of py-files depend on?
You should execute the werkzeug server with the --dev flag.
trytond --dev will restart the server once a file is changed and reload the changes. trytond won’t restart if any file is changed and keep running the loaded version unless you restart it explicitly.
Both servers are started with trytond --dev. Both servers restart after changing py-files. On one server the py-files are automatically compiled, but on the second server they are not.
This is Python feature. I guess the user running trytond has no write-access on the proper folder to store compiled files.
But any way it is a bad idea to run in production with the werkzeug development server and even worse with the development mode.
It is also a bad idea if the user running the server has write-access to the code source as this remove a layer of security protection in case of attack.
Finally you can use compileall to compile in advance the Python files.
Оn the first server the owner and group tryton had write permissions to the folders __pycache__. But on the second server, only the owner had write permissions to these folders.
However, it turned out that automatic compilation is performed only if there are no errors in py-files. After any error, you have to run compileall. It would be cool if automatic compilation was always performed, even after fixing errors in py-files.
Yes, after fixing the syntax error, you will have to restart the server manually. Then the watchdog reloader works again. Many thanks for the good advice.