Error When Switch ERPNext v13 Environment from Development to Production

Dear All,

I have faced an error when I want to switch ERPNext v13 from development to producation.

Note:
This error showed after running this:

sudo bench setup production frappe

Please any help !!


Site site1.local assigned port: 8001
Setting Up symlinks and reloading services...
$ /usr/bin/supervisorctl reread
frappe-bench-redis: available
frappe-bench-web: available
frappe-bench-workers: available
$ /usr/bin/supervisorctl update
frappe-bench-redis: added process group
frappe-bench-web: added process group
frappe-bench-workers: added process group
$ sudo /usr/sbin/nginx -t
nginx: [emerg] unknown log format "main" in /etc/nginx/conf.d/frappe-bench.conf:101
nginx: configuration file /etc/nginx/nginx.conf test failed
ERROR:
Traceback (most recent call last):
  File "/usr/local/bin/bench", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.8/dist-packages/bench/cli.py", line 127, in cli
    bench_command()
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/bench/commands/setup.py", line 89, in setup_production
    setup_production(user=user, yes=yes)
  File "/usr/local/lib/python3.8/dist-packages/bench/config/production_setup.py", line 87, in setup_production
    reload_nginx()
  File "/usr/local/lib/python3.8/dist-packages/bench/config/production_setup.py", line 205, in reload_nginx
    exec_cmd(f"sudo {which('nginx')} -t")
  File "/usr/local/lib/python3.8/dist-packages/bench/utils/__init__.py", line 155, in exec_cmd
    raise CommandFailedError
bench.exceptions.CommandFailedError

1 Like

See this

@avc

Thank you for your response, but the error still exists.

Yes. Read the thread … you can downgrade bench version, or define main log format …

@ERP_Implementer1 what’s the output of “systemctl status nginx”

Basically, nginx -t test the nginx.conf file … and it is failing because main format is not defined. Nginx will not start in this case.

Main format can be defined this way

If you change manually the nginx.conf deleting “main” modificator, nginx will run anyway but … after bench setup production or bench setup nginx will broke the file again …

I’ve been informed that nginx can be installed from bench → bench install nginx
This will set the log format properly. I’ve never try this way, always install nginx from apt.

bench 5.14.00 is avaliable.

update bench with
sudo -H pip3 install --upgrade frappe-bench

Then, config nginx without log format
bench setup nginx --log_format ‘’

1 Like

Dear @avc,

Thank you for your help.

I have reinstalled it from the beginning in a manually.