Some services depend on/access others. As DietPi-Services starts and stops them in the same order, there are short time spans, where errors can occur. I sometimes see access errors on database access tries or cron jobs accessing to web server e.g., during the many start/stop/restarts, done during testing installations.
We could reorder some obvious services and go through the array backwards (if possible), if services are stopped:
On restart of course we can't fully prevent those errors, but the affected time spans are again shorter.
If this is guaranteed, I will also add ownCloud/Nextcloud maintenance mode as oneshot systemd services, once implemented and remove their current exceptional position from dietpi-services code ๐.
Same could be done for installation/uninstallation:
Other specific issue of uninstall order: https://github.com/Fourdee/DietPi/issues/1523
I have two ideas:
if [[ "$@" =~ ' 23 ' ]];
instead of if (( $index == 23 ))
apt-mark auto
and let G_AGA to actual purging in it's preferred order. Would need testing, especially dpkg -P
would need to be handled separately, but at least those manual installed package titles are mostly (needs review) no dependencies of others.@MichaIng
Sent commit to reverse stop order https://github.com/Fourdee/DietPi/commit/08b8e913e79140ffa34bee2335307567598f2f52
Mode: start
[ OK ] DietPi-Services | start : cron
[ OK ] DietPi-Services | start : lighttpd
[ OK ] DietPi-Services | start : php7.0-fpm
[ OK ] DietPi-Services | start : mysql
[ OK ] DietPi-Services | start : redis-server
[ OK ] DietPi-Services | start : mpd
[ OK ] DietPi-Services | start : avahi-daemon
---
Mode: stop
[ OK ] DietPi-Services | ncc maintenance:mode --on
[ OK ] DietPi-Services | stop : avahi-daemon
[ OK ] DietPi-Services | stop : mpd
[ OK ] DietPi-Services | stop : redis-server
[ OK ] DietPi-Services | stop : mysql
[ OK ] DietPi-Services | stop : php7.0-fpm
[ OK ] DietPi-Services | stop : lighttpd
[ OK ] DietPi-Services | stop : cron
@Fourdee
Nice one! I will now try to reorder a bid.
ToDo:
dietpi-software
Uninstall ordering. (https://github.com/Fourdee/DietPi/issues/1462#issuecomment-368322674)@Fourdee
I was playing around a bid:
Uninstall_Banner(){
echo ''
G_DIETPI-NOTIFY 0 "Uninstalling ${aSOFTWARE_WHIP_NAME[$uninstall_index]}: ${aSOFTWARE_WHIP_DESC[$uninstall_index]}\n"
}
Uninstall_Software(){
#NB: systemctl daemon-reload is executed after this func in Uninstall_Software_Finalize()
local uninstall_list=" $@ "
#----------------------------------------------------------------------
#Inform User
G_DIETPI-NOTIFY 3 "$G_PROGRAM_NAME" "Uninstall"
#echo -e ""
#G_DIETPI-NOTIFY 0 "Uninstalling ${aSOFTWARE_WHIP_NAME[$index]}: ${aSOFTWARE_WHIP_DESC[$index]}\n"
#Was a uninstall event trigged?
local valid_input=1
#----------------------------------------------------------------------
#DIETPI SOFTWARE
local uninstall_index=23
if [[ "$uninstall_list" =~ " $uninstall_index " ]]; then
Uninstall_Banner
G_AGP lxde lxde-* upower policykit-1 iceweasel
fi
uninstall_index=24
if [[ "$uninstall_list" =~ " $uninstall_index " ]]; then
Uninstall_Banner
G_AGP mate-desktop-environment-extras upower policykit-1 iceweasel
...
Input_Modes(){
...
if [ "$1" = "uninstall" ]; then
Uninstall_Software "${ainput[@]}"
Uninstall_Software_Finalize
md5-080117febec632739232b45679a36138
Uninstall_NonSelected_Choices(){
#Uninstall software using our temp uninstall list
if [ -f "$UNINSTALL_FILE" ]; then
local uninstall_list
#Run the temp uninstall script
while read -r line
do
uninstall_list+=" $line "
done < $UNINSTALL_FILE
Uninstall_Software "$uninstall_list"
rm $UNINSTALL_FILE
fi
}
Generally it works, but printing uninstall info to log and adjusting /DietPi/dietpi/.installed
needs to be inside every if statement as well. A lot of additional lines, much work anyway. I don't like it too much.
Second solution with just apt-mark auto and autoremove everything afterwards is also not a really nice solution, as it is a bid in-transparent, what is done due to which uninstall. I would like to have most things done within the single uninstall statements.
Maybe we could handle it similar than for installation? Add a new uninstall flag -1
to /DietPi/dietpi/.installed
and check for this within Uninstall_Software()? It maybe needs as much work as the other solutions above, but at least we can just copy the methods from installation and be consistent here. This would enable us as well to use the same functions for both, reading string and adjusting /DietPi/dietpi/.installed
just based of where we come from, install- or uninstall menu respectively "$1".
@MichaIng Great work ๐, can we mark this as closed?
@Fourdee
I am just at the same topic right now, actually ordering services atm. found some other issue while doing this ๐. I will just post final results here fore completeness and then mark as closed.
@MichaIng
and in case database active to serve it's content, it is best to stop it first and start is last
Done: https://github.com/Fourdee/DietPi/commit/e7c1f6164fabe746c75ced70504a8359740eba47
This brings the webserver ordering to same as previous (eg: v6.3). I'll mark this as closed, however, please reopen if required or needs adjusting.
@Fourdee
Whoops, did I write it that way? Can't find my comment anymore I meant database should be started first, webserver last. The pre 6.3 state caused the errors, as webserver (respectively PHP connector) want to, but can't access database then.
I already tested it on VM and RPi, works fine and resolves error messages.
Commit: https://github.com/Fourdee/DietPi/commit/3a287e2338ce592cb4ce03cafb244fd57196a767
@MichaIng
Legend thank you ๐
Can't find my comment anymore
https://github.com/Fourdee/DietPi/pull/1650#issuecomment-377008918, although, I probably misread/understood it entirely ๐
Most helpful comment
@Fourdee
Whoops, did I write it that way? Can't find my comment anymore I meant database should be started first, webserver last. The pre 6.3 state caused the errors, as webserver (respectively PHP connector) want to, but can't access database then.
I already tested it on VM and RPi, works fine and resolves error messages.
Commit: https://github.com/Fourdee/DietPi/commit/3a287e2338ce592cb4ce03cafb244fd57196a767