[URGENT]bench restart gives permission denied 13 error in production mode

Hello
here I am trying to set up a production instance and I suppose supervisorctl is getting restricted i suppose i am just onr step away …can anyway guide me through what should i do here or what am i doing wrong
Thank you

 bench restart
$ supervisorctl restart frappe:
error: <class 'PermissionError'>, [Errno 13] Permission denied: file: /usr/lib/p                                                                                                             ython3/dist-packages/supervisor/xmlrpc.py line: 560
ERROR:
Traceback (most recent call last):
  File "/usr/local/bin/bench", line 8, in <module>
    sys.exit(cli())
  File "/home/frappe/.bench/bench/cli.py", line 127, in cli
    bench_command()
  File "/usr/lib/python3/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/frappe/.bench/bench/commands/utils.py", line 41, in restart
    Bench(".").reload(web, supervisor, systemd)
  File "/home/frappe/.bench/bench/utils/render.py", line 126, in wrapper_fn
    return fn(*args, **kwargs)
  File "/home/frappe/.bench/bench/bench.py", line 150, in reload
    restart_supervisor_processes(bench_path=self.name, web_workers=web)
  File "/home/frappe/.bench/bench/utils/bench.py", line 304, in restart_supervis                                                                                                             or_processes
    bench.run(f"{sudo}supervisorctl restart {group}")
  File "/home/frappe/.bench/bench/bench.py", line 47, in run
    return exec_cmd(cmd, cwd=cwd or self.cwd)
  File "/home/frappe/.bench/bench/utils/__init__.py", line 155, in exec_cmd
    raise CommandFailedError
bench.exceptions.CommandFailedError

1 Like

Maybe you should change ownership, as well as their read/write/exe and try again.

sudo chmodsudo chmod -R u+rwX,go+rX,go-w /path/to/path

sudo chown USER:GROUP -R /path/to/path

hey thanks for such quick reply
i was trying that but i am not getting which file should be given the ownership and permissions

If you’re giving bench setup production, you should change to root user and execute sudo bench setup production USER (the user Frappe bench is installed under). Bench would then confirm with you to allow the USER to execute supervisor commands and you should be set.

Okay something like this? @iMoshi

frappe@nova14erpuat:~/frappe-bench$ sudo su -
root@nova14erpuat:/# cd /home
root@nova14erpuat:/home# ls
frappe  novaadmin
root@nova14erpuat:/home# cd frappe/frappe-bench
root@nova14erpuat:/home/frappe/frappe-bench# ls
apps  config  env  logs  patches.txt  Procfile  sites
root@nova14erpuat:/home/frappe/frappe-bench# sudo bench setup production frappe
Setting Up prerequisites...
Setting Up supervisor...
supervisor.conf already exists and this will overwrite it. Do you want to continue? [y/N]: y
Setting Up NGINX...
nginx.conf already exists and this will overwrite it. Do you want to continue? [y/N]: y
Port configuration list:

Site nova14erpuat.northeurope.cloudapp.azure.com assigned port: 80
Setting Up symlinks and reloading services...
$ /usr/bin/supervisorctl reread
No config updates to processes
$ /usr/bin/supervisorctl update
$ sudo /usr/sbin/nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
$ sudo systemctl reload nginx
root@nova14erpuat:/home/frappe/frappe-bench# sudo su - frappe
frappe@nova14erpuat:~$ cd frappe-bench
frappe@nova14erpuat:~/frappe-bench$ bench restart
$ supervisorctl restart frappe:
error: <class 'PermissionError'>, [Errno 13] Permission denied: file: /usr/lib/python3/dist-packages/supervisor/xmlrpc.py line: 560
ERROR:
Traceback (most recent call last):
  File "/usr/local/bin/bench", line 8, in <module>
    sys.exit(cli())
  File "/home/frappe/.bench/bench/cli.py", line 127, in cli
    bench_command()
  File "/usr/lib/python3/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/frappe/.bench/bench/commands/utils.py", line 41, in restart
    Bench(".").reload(web, supervisor, systemd)
  File "/home/frappe/.bench/bench/utils/render.py", line 126, in wrapper_fn
    return fn(*args, **kwargs)
  File "/home/frappe/.bench/bench/bench.py", line 150, in reload
    restart_supervisor_processes(bench_path=self.name, web_workers=web)
  File "/home/frappe/.bench/bench/utils/bench.py", line 304, in restart_supervisor_processes
    bench.run(f"{sudo}supervisorctl restart {group}")
  File "/home/frappe/.bench/bench/bench.py", line 47, in run
    return exec_cmd(cmd, cwd=cwd or self.cwd)
  File "/home/frappe/.bench/bench/utils/__init__.py", line 155, in exec_cmd
    raise CommandFailedError
bench.exceptions.CommandFailedError

In your bench as the frappe user, run:
bench setup systemd –-user frappe

2 Likes