Service having an application startup error causes all applications and listeners to be lost after restarting unit
I have a simple config and whenever there is a startup error with the application the next unit restart causes all applications and listeners to be lost.
curl http://127.0.0.1:8080/config yields:
{
"listeners": {
"*:8444": {
"application": "hello_world"
}
},
"applications": {
"hello_world": {
"type": "python 3",
"processes": 2,
"user": "unit",
"group": "unit",
"path": "/opt/unit/hello_world",
"module": "service",
}
}
}
For example, the hello_world python app has an import error, then when attempting to restart unit with sudo service restart unit or sudo /etc/init.d/unit restart causes all applications and listeners to be lost (unit.log):
2020/01/08 10:36:21 [alert] 7662#7662 Python failed to import module "service"
2020/01/08 10:36:22 [notice] 7651#7651 process 7662 exited with code 1
2020/01/08 10:36:22 [warn] 7660#7660 failed to start application "dialogflow-webhook"
2020/01/08 10:36:22 [alert] 7660#7660 failed to apply new conf
2020/01/08 10:36:22 [alert] 7659#7659 failed to apply previous configuration
2020/01/08 10:36:22 [notice] 7651#7651 process 7661 exited with code 0
Running curl http://127.0.0.1:8080/config then yields this:
{
"listeners": {},
"applications": {}
}
Running with:
unit version: 1.8.0
Linux system 4.19.29-0-vanilla #1-Alpine SMP Mon Mar 18 21:25:27 UTC 2019 x86_64 Linux
Hi! Is there any new information related to this issue? We have the same problem. Currently we have to run Unit in different docker containers for each app to avoid crushing all of apps at once. It's not very convenient.
restart may be be a little heavy handed, does reload behave differently?
It might also help to restart only the faulty application instead of the entire service. https://unit.nginx.org/configuration/#process-management
Also, you can
GETthe /control/applications/ section of the API to restart an app For example:
unitc /control/applications/hello_world/restart