@@ -24,7 +24,7 @@ function show_usage() {
24
24
test [PKG] Deploy, update and run tests for some packages
25
25
Tests for single modules and functions can ran with
26
26
e.g. ./ynh-dev test yunohost/appurl:urlavailable
27
- dev Watch python files and restart yunohost-api and yunohost-portal-api when changes occur
27
+ api Start yunohost-api and yunohost-portal-api in debug mode in the current terminal, and auto-restart them when code changes
28
28
catalog
29
29
build Rebuild the custom catalog
30
30
add Add the custom catalog in Yunohost catalog list
@@ -53,8 +53,8 @@ function main()
53
53
54
54
ip|--ip) show_vm_ip " ${ARGUMENTS[@]} " ;;
55
55
use-git|--use-git) use_git " ${ARGUMENTS[@]} " ;;
56
- dev |--dev ) dev " ${ARGUMENTS[@]} " ;;
57
- lint|--lint) run_linters " ${ARGUMENTS[@]} " ;;
56
+ api |--api ) api " ${ARGUMENTS[@]} " ;;
57
+ lint|--lint) run_linters " ${ARGUMENTS[@]} " ;;
58
58
test|--test) run_tests " ${ARGUMENTS[@]} " ;;
59
59
60
60
catalog|--catalog) catalog " ${ARGUMENTS[@]} " ;;
@@ -448,23 +448,34 @@ $IP $MAIN_DOMAIN"
448
448
done
449
449
}
450
450
451
- function dev ()
451
+ function api ()
452
452
{
453
453
assert_inside_vm
454
454
455
455
command -v inotifywait & > /dev/null || critical " You should first run: apt install inotify-tools"
456
456
457
- info " Now monitoring for changes in python files, restarting yunohost-api and yunohost-portal-api when changes occur!"
457
+ function kill_and_restart_api()
458
+ {
459
+ systemctl --quiet is-active yunohost-api && systemctl stop yunohost-api || true
460
+ systemctl --quiet is-active yunohost-portal-api && systemctl stop yunohost-portal-api || true
461
+ for PID in $( pgrep -f yunohost-api) $( pgrep -f yunohost-portal-api) ; do kill $PID ; done
462
+ yunohost-api --debug &
463
+ yunohost-portal-api --debug &
464
+ }
458
465
459
- journalctl --no-pager --no-hostname -u yunohost-api -u yunohost-portal-api -n 0 -f &
460
- JOURNALCTL_PID=$!
466
+ info " Now monitoring for changes in python files, restarting yunohost-api and yunohost-portal-api when changes occur!"
461
467
462
- trap ' kill $JOURNALCTL_PID; exit' SIGINT
468
+ kill_and_restart_api
469
+ trap ' for PID in $(pgrep -f yunohost-api) $(pgrep -f yunohost-portal-api); do kill $PID; done; exit' SIGINT
463
470
464
- while ! inotifywait -q - e modify /usr/lib/python3/dist-packages/{moulinette, yunohost}/{ * .py, * / * .py }
471
+ while { inotifywait --quiet -r - e modify /ynh-dev/yunohost/share /ynh-dev/ yunohost/locales/ /ynh-dev/yunohost/src /ynh-dev/moulinette/moulinette --exclude " (test_|\.pyc) " || true ; }
465
472
do
473
+ echo " "
474
+ echo " =========================="
466
475
info " Restarting services"
467
- systemctl restart yunohost-api yunohost-portal-api
476
+ echo " =========================="
477
+ echo " "
478
+ kill_and_restart_api
468
479
done
469
480
470
481
}
0 commit comments