How to prevent `bench update` to restart supervisor and require sudo?

I just installed the latest version of ERPNext and then run an update to test it.
I automated installation using Ansible with a user frappe that does not have sudo permissions and does not have a password.
Then I run bench update as user frappe and Ansible fails because user frappe cannot execute using sudo and restart supervisorctl.

Running the command manually the error loos like this:

Wrote ./assets/js/d3.min.js - 343k
Wrote ./assets/css/form.min.css - 4k
[sudo] password for frappe: 
Sorry, try again.
[sudo] password for frappe: 
Sorry, try again.
[sudo] password for frappe: 
sudo: 3 incorrect password attempts
Traceback (most recent call last):
  File "/usr/local/bin/bench", line 11, in <module>
    load_entry_point('bench', 'console_scripts', 'bench')()
  File "/srv/frappe/bench-repo/bench/", line 40, in cli
  File "/usr/local/lib/python2.7/dist-packages/click/", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/dist-packages/click/", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/dist-packages/click/", line 535, in invoke
    return callback(*args, **kwargs)
  File "/srv/frappe/bench-repo/bench/commands/", line 62, in update
    _update(pull, patch, build, bench, auto, restart_supervisor, requirements, no_backup, upgrade, force=force, reset=reset)
  File "/srv/frappe/bench-repo/bench/commands/", line 103, in _update
  File "/srv/frappe/bench-repo/bench/", line 344, in restart_supervisor_processes
    supervisor_status = subprocess.check_output(['sudo', 'supervisorctl', 'status'], cwd=bench_path)
  File "/usr/lib/python2.7/", line 574, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['sudo', 'supervisorctl', 'status']' returned non-zero exit status 1

I don’t want to give user frappe permissions to run sudo commands.
How can I prevent bench update to restart supervisor? I can restart it later with a different user, but if bench update fails, I can’t automate the updates.

1 Like

IIRC, you can split bench update into subset of commands like bench update --pull && bench update --patch && bench update --build && bench update --bench, omitting bench update --restart-supervisor¹.
I can be wrong about the consequence of commands though.

¹ — Bench commands cheatsheet

@dkastl, @strixaluco,

you can set the restart_supervisor_on_update to false in common site config once set to false the supervisor will not restart on bench update


@makarand_b, changing the configuration worked! Thanks a lot!

About running the commands separately I had already tried

bench update --pull --patch --build --bench --requirements --upgrade

… but without success. It still wants to restart supervisord in the end.
Also when I tried bench update --pull for example as recommended by @strixaluco, the same result.

I’m not sure, this is an intended behaviour, that supervisorctl will be called even if you omit --restart-supervisor. Or eventually this is a bug. With the config settings though it works now.

1 Like

system will check both --restart-supervisor and restart_supervisor_on_update parameters if one of them is true then it restarts the supervisor