From 357d497e5591f910dfa0972933e46b0297d6cb62 Mon Sep 17 00:00:00 2001 From: Ameya Shenoy Date: Thu, 22 Mar 2018 15:21:50 +0530 Subject: [PATCH] restart supervisor on boot This is being added to restart supervisor inside the virtual machine on boot, since the command 'bench update' breaks on boot, since the supervisor is not active. This is a bug in debian, which has been propogated to ubuntu, and this piece of code can be removed when the bug is fixed. --- bench/utils.py | 2 -- vm/scripts/restart_supervisor.sh | 14 ++++++++++++++ vm/vm-develop.json | 4 ++++ vm/vm-production.json | 4 ++++ 4 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 vm/scripts/restart_supervisor.sh diff --git a/bench/utils.py b/bench/utils.py index f73eb2e0..fd3db388 100755 --- a/bench/utils.py +++ b/bench/utils.py @@ -407,8 +407,6 @@ def restart_supervisor_processes(bench_path='.', web_workers=False): else: group = 'frappe:' - if find_executable('systemctl'): - exec_cmd('sudo systemctl restart supervisor.service && sleep 1') exec_cmd('sudo supervisorctl restart {group}'.format(group=group), cwd=bench_path) def set_default_site(site, bench_path='.'): diff --git a/vm/scripts/restart_supervisor.sh b/vm/scripts/restart_supervisor.sh new file mode 100644 index 00000000..0afad870 --- /dev/null +++ b/vm/scripts/restart_supervisor.sh @@ -0,0 +1,14 @@ +#! /bin/bash + + +# Write out current crontab +crontab -l > current_cron + +# Echo new cron into cron file +echo "@reboot sleep 20 && systemctl restart supervisor" >> current_cron + +# Install new cron file +crontab current_cron + +# Delete the temporary cron file +rm current_cron \ No newline at end of file diff --git a/vm/vm-develop.json b/vm/vm-develop.json index 8d92fd9c..c131e669 100644 --- a/vm/vm-develop.json +++ b/vm/vm-develop.json @@ -80,6 +80,10 @@ }, { "type": "shell", "script": "scripts/set_message.sh" + }, { + "type": "shell", + "execute_command": "echo 'frappe' | {{.Vars}} sudo -S -E bash '{{.Path}}'", + "script": "scripts/restart_supervisor.sh" }], "post-processors": [{ "type": "checksum", diff --git a/vm/vm-production.json b/vm/vm-production.json index ce478fa9..b43828b2 100644 --- a/vm/vm-production.json +++ b/vm/vm-production.json @@ -80,6 +80,10 @@ }, { "type": "shell", "script": "scripts/set_message.sh" + }, { + "type": "shell", + "execute_command": "echo 'frappe' | {{.Vars}} sudo -S -E bash '{{.Path}}'", + "script": "scripts/restart_supervisor.sh" }], "post-processors": [{ "type": "checksum",