The interface for reloading applications is planned.
Currently, an application can be reloaded by changing its name.
More specifically, in order to ensure smooth transition to the new application version, you can you the following workflow:
/listeners/<id>/application object in the API to the name of new application, using PUT request. Now traffic will be served by the new application.DELETE request to the API.How to apply changes to wsgi.py?
It's very critical. Delete and create the applet incorrectly
Reload is required for python.
+1. It's very important feature.
+1
Hello,
Any info about this issue ? I can confirm it still exists with the latest version of unit - 1.4. Changes to the application are not applied unless it is reconfigured as a new application within unit, or deleted and sent to the unit configuration with the same settings again.
I've had the same issue, and worked around it by adding the current timestamp as an environment variable in my application. Although it seems hacky, I haven't had any issues with it so far. If the environment changes, the application is forced to reload in order to pick up the change.
curl -X PUT -d '{"APPVERSION":"'$(date +"%s")'"}' --unix-socket /var/run/control.unit.sock http://localhost/config/applications/myapp/environment
The upside to this is there is no need to update your application name or port.
@andyvanee Yes, for now that's one of the best workarounds. Usually I recommend something like this:
curl -X PUT -d "{\"gen\":\"$RANDOM\"}" --unix-socket /var/run/control.unit.sock /config/applications/<name>/environment
The interface for controlling application processes is planned for Q1/2019. Then the restarting processes command will be straightforward:
curl --unix-socket /var/run/control.unit.sock /control/applications/<name>/restart
Edit: Sorry, Q1 is passed. Q3/2019 is more realistic now (upd: moved to Q1/2020)
Ubuntu 18.04, I use systemctl restart unit and it looks fine
@xiangnanscu I think the point is to be able to restart a single service - if you have many services running, you don't want to restart all of them just to reload a single one.
You can kill the PIDs for now. Until this is resolved it may be best to generate a script that kills multiple PIDs related to a service when the service is initiated (per process).
I've had the same issue, and worked around it by adding the current timestamp as an environment variable in my application. Although it seems hacky, I haven't had any issues with it so far. If the environment changes, the application is forced to reload in order to pick up the change.
curl -X PUT -d '{"APPVERSION":"'$(date +"%s")'"}' --unix-socket /var/run/control.unit.sock http://localhost/config/applications/myapp/environmentThe upside to this is there is no need to update your application name or port.
Info for those noobs as me - in json file it would be:
"environment": {
"APPVERSION": "$(date + %s)"
}
I've had the same issue, and worked around it by adding the current timestamp as an environment variable in my application. Although it seems hacky, I haven't had any issues with it so far. If the environment changes, the application is forced to reload in order to pick up the change.
curl -X PUT -d '{"APPVERSION":"'$(date +"%s")'"}' --unix-socket /var/run/control.unit.sock http://localhost/config/applications/myapp/environment
The upside to this is there is no need to update your application name or port.Info for those noobs as me - in json file it would be:
"environment": { "APPVERSION": "$(date + %s)" }
It's a shell expression that substitutes current timestamp:
$ echo '{"APPVERSION":"'$(date +"%s")'"}'
{"APPVERSION":"1572958385"}
Issue still there.
Workaround also still works. Ansible template example:
"applications": {
"flask_app": {
...
"environment": {
"version": "{{ '%Y-%m-%d_%H:%M:%S' | strftime }}"
}
}
}
Thanks to everyone suggesting their workarounds! Here's the doc piece: https://unit.nginx.org/configuration/#configuration-management
Most helpful comment
@andyvanee Yes, for now that's one of the best workarounds. Usually I recommend something like this:
curl -X PUT -d "{\"gen\":\"$RANDOM\"}" --unix-socket /var/run/control.unit.sock /config/applications/<name>/environmentThe interface for controlling application processes is planned for Q1/2019. Then the restarting processes command will be straightforward:
curl --unix-socket /var/run/control.unit.sock /control/applications/<name>/restartEdit: Sorry, Q1 is passed. Q3/2019 is more realistic now (upd: moved to Q1/2020)