mirror of
https://github.com/YunoHost/ynh-dev.git
synced 2024-09-03 20:05:59 +02:00
Add a 'dev' command to watch for changes in python files and auto-restart APIs
This commit is contained in:
parent
f378bd610c
commit
5c8e3e773b
1 changed files with 23 additions and 0 deletions
23
ynh-dev
23
ynh-dev
|
@ -19,6 +19,7 @@ function show_usage() {
|
||||||
test [PKG] Deploy, update and run tests for some packages
|
test [PKG] Deploy, update and run tests for some packages
|
||||||
Tests for single modules and functions can ran with
|
Tests for single modules and functions can ran with
|
||||||
e.g. ./ynh-dev test yunohost/appurl:urlavailable
|
e.g. ./ynh-dev test yunohost/appurl:urlavailable
|
||||||
|
dev Watch python files and restart yunohost-api and yunohost-portal-api when changes occur
|
||||||
catalog
|
catalog
|
||||||
build Rebuild the custom catalog
|
build Rebuild the custom catalog
|
||||||
add Add the custom catalog in Yunohost catalog list
|
add Add the custom catalog in Yunohost catalog list
|
||||||
|
@ -47,6 +48,7 @@ function main()
|
||||||
|
|
||||||
ip|--ip) show_vm_ip $ARGUMENTS ;;
|
ip|--ip) show_vm_ip $ARGUMENTS ;;
|
||||||
use-git|--use-git) use_git $ARGUMENTS ;;
|
use-git|--use-git) use_git $ARGUMENTS ;;
|
||||||
|
dev|--dev) dev $ARGUMENTS ;;
|
||||||
test|--test) run_tests $ARGUMENTS ;;
|
test|--test) run_tests $ARGUMENTS ;;
|
||||||
|
|
||||||
catalog|--catalog) catalog $ARGUMENTS ;;
|
catalog|--catalog) catalog $ARGUMENTS ;;
|
||||||
|
@ -423,6 +425,27 @@ $IP $MAIN_DOMAIN"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function dev()
|
||||||
|
{
|
||||||
|
assert_inside_vm
|
||||||
|
|
||||||
|
which inotifywait &>/dev/null || critical "You should first run: apt install inotify-tools"
|
||||||
|
|
||||||
|
info "Now monitoring for changes in python files, restarting yunohost-api and yunohost-portal-api when changes occur!"
|
||||||
|
|
||||||
|
journalctl --no-pager --no-hostname -u yunohost-api -u yunohost-portal-api -n 0 -f &
|
||||||
|
JOURNALCTL_PID=$!
|
||||||
|
|
||||||
|
trap "kill $JOURNALCTL_PID; exit" SIGINT
|
||||||
|
|
||||||
|
while ! inotifywait -q -e modify /usr/lib/python3/dist-packages/{moulinette,yunohost}/{*.py,*/*.py}
|
||||||
|
do
|
||||||
|
info "Restarting services"
|
||||||
|
systemctl restart yunohost-api yunohost-portal-api
|
||||||
|
done
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function run_tests()
|
function run_tests()
|
||||||
{
|
{
|
||||||
assert_inside_vm
|
assert_inside_vm
|
||||||
|
|
Loading…
Add table
Reference in a new issue