Erpnext Official Docker too slow

Hi guys,

I´m using docker for developing enviroment. I have two problems:

  • bench start is too slow, It takes almost 3 minutes to begin. I know that is in a virtual machine, but If you compare with the ubuntu standalone installation it´s very slow.
  • When I change in the code in my custom app the service doestn`t reload with the modifications. That is a problem for me because I have to restart the service each time that I want to debug a fix.

My host machine is:
Asus Laptop, i7, 8GB Ram, 240 SSD
OS: Windows 10 Home

Docker Toolbox with Virtual Box. The virtual machine has 2 cpu and 4GB RAM

erpnext 10.1.75
foundation 0.0.1
frappe 10.1.67

This is the log when I run “bench start”:
frappe@16db98dcc0a5:~/frappe-bench$ bench start
10:43:23 system | worker_long.1 started (pid=60)
10:43:23 system | socketio.1 started (pid=67)
10:43:23 system | web.1 started (pid=65)
10:43:23 system | watch.1 started (pid=64)
10:43:23 system | worker_short.1 started (pid=69)
10:43:23 system | worker_default.1 started (pid=68)
10:43:24 system | schedule.1 started (pid=66)
10:43:31 socketio.1 | listening on *: 9000
10:45:25 worker_short.1 | 10:45:25 RQ worker u’rq:worker:16db98dcc0a5.84.short’ started, version 0.12.0
10:45:25 worker_short.1 | 10:45:25 *** Listening on short…
10:45:25 worker_short.1 | 10:45:25 Cleaning registries for queue: short
10:45:25 worker_default.1 | 10:45:25 RQ worker u’rq:worker:16db98dcc0a5.87.default’ started, version 0.12.0
10:45:25 worker_default.1 | 10:45:25 *** Listening on default…
10:45:25 worker_default.1 | 10:45:25 Cleaning registries for queue: default
10:45:25 worker_long.1 | 10:45:25 RQ worker u’rq:worker:16db98dcc0a5.73.long’ started, version 0.12.0
10:45:25 worker_long.1 | 10:45:25 *** Listening on long…
10:45:25 worker_long.1 | 10:45:25 Cleaning registries for queue: long
10:45:27 web.1 | * Running on http://0.0.0.0:8000/ (Press CTRL+C to quit)
10:45:27 web.1 | * Restarting with inotify reloader
10:45:37 watch.1 | compiling avatar.less
10:45:37 watch.1 | compiling calendar.less
10:45:37 watch.1 | compiling common.less
10:45:37 watch.1 | compiling controls.less
10:45:37 watch.1 | compiling desk.less
10:45:37 watch.1 | compiling desktop.less
10:45:37 watch.1 | compiling docs.less
10:45:37 watch.1 | compiling email.less
10:45:37 watch.1 | compiling form.less
10:45:37 watch.1 | compiling form_grid.less
10:45:37 watch.1 | compiling gantt.less
10:45:38 watch.1 | compiling indicator.less
10:45:38 watch.1 | compiling kanban.less
10:45:38 watch.1 | compiling list.less
10:45:38 watch.1 | compiling mixins.less
10:45:38 watch.1 | compiling mobile.less
10:45:38 watch.1 | compiling module.less
10:45:38 watch.1 | compiling navbar.less
10:45:38 watch.1 | compiling page.less
10:45:38 watch.1 | compiling report.less
10:45:38 watch.1 | compiling role_editor.less
10:45:38 watch.1 | compiling sidebar.less
10:45:38 watch.1 | compiling slickgrid.less
10:45:38 watch.1 | compiling tags.less
10:45:38 watch.1 | compiling tree.less
10:45:38 watch.1 | compiling website.less
10:45:38 watch.1 | compiling email.less
10:45:38 watch.1 | compiling erpnext.less
10:45:38 watch.1 | compiling hub.less
10:45:38 watch.1 | compiling pos.less
10:45:38 watch.1 | compiling website.less
10:45:38 watch.1 | file watching on *: 6787
10:45:40 watch.1 | Less files compiled
10:45:40 watch.1 | Wrote css/frappe-web.css - 65.43 KB
10:45:40 watch.1 | Wrote js/frappe-web.min.js - 135.26 KB
10:45:40 watch.1 | Wrote js/control.min.js - 81.7 KB
10:45:40 watch.1 | Wrote js/dialog.min.js - 124.34 KB
10:45:41 watch.1 | Wrote css/desk.min.css - 310.94 KB
10:45:41 watch.1 | Wrote css/frappe-rtl.css - 32.73 KB
10:45:41 watch.1 | Wrote js/libs.min.js - 1.13 MB
10:45:42 watch.1 | Wrote js/desk.min.js - 481.11 KB
10:45:42 watch.1 | Wrote css/module.min.css - 2.16 KB
10:45:42 watch.1 | Wrote css/form.min.css - 4.55 KB
10:45:42 watch.1 | Wrote js/form.min.js - 205.97 KB
10:45:42 watch.1 | Wrote css/list.min.css - 13.67 KB
10:45:42 watch.1 | Wrote js/list.min.js - 161.88 KB
10:45:42 watch.1 | Wrote css/report.min.css - 8.31 KB
10:45:42 watch.1 | Wrote js/report.min.js - 263.25 KB
10:45:42 watch.1 | Wrote js/web_form.min.js - 248.66 KB
10:45:42 watch.1 | Wrote css/web_form.css - 24.69 KB
10:45:43 watch.1 | Wrote js/print_format_v3.min.js - 25.87 KB
10:45:43 watch.1 | Wrote css/erpnext.css - 8.17 KB
10:45:43 watch.1 | Wrote js/erpnext-web.min.js - 4.23 KB
10:45:43 watch.1 | Wrote js/erpnext.min.js - 170.89 KB
10:45:43 watch.1 | Wrote js/item-dashboard.min.js - 8.48 KB
10:45:43 watch.1 | Wrote css/jasper_erpnext_report.css - 27.75 KB
10:45:43 watch.1 | Wrote js/jasper_erpnext_report.js - 189.11 KB
10:46:07 web.1 | * Debugger is active!
10:46:07 web.1 | * Debugger PIN: 330-808-860

Finally,
I want to thank to the developers and the community for this awesome platform.

Try adding by adding reloader_type='stat', to run_simple command in /apps/frappe/frappe/apps.py

So it should be like this.

def serve(port=8000, profile=False, no_reload=False, no_threading=False, site=None, sites_path='.'):
    global application, _site, _sites_path
    _site = site
    _sites_path = sites_path

    from werkzeug.serving import run_simple

    if profile:
            application = ProfilerMiddleware(application, sort_by=('cumtime', 'calls'))

    if not os.environ.get('NO_STATICS'):
            application = SharedDataMiddleware(application, {
                    '/assets': os.path.join(sites_path, 'assets'),
            })

            application = StaticDataMiddleware(application, {
                    '/files': os.path.abspath(sites_path)
            })

    application.debug = True
    application.config = {
            'SERVER_NAME': 'localhost:8000'
    }

    in_test_env = os.environ.get('CI')
    if in_test_env:
            log = logging.getLogger('werkzeug')
            log.setLevel(logging.ERROR)

    run_simple('0.0.0.0', int(port), application,
            reloader_type='stat',
            use_reloader=False if in_test_env else not no_reload,
            use_debugger=not in_test_env,
            use_evalex=not in_test_env,
            threaded=not no_threading)

Hi pipech,
Thanks for your fast anwser

I’ve done what you have proposed and the problem persist.

The server starts with the option that you recomend as, I can see in the log:
14:54:37 web.1 | * Running on http://0.0.0.0:8000/ (Press CTRL+C to quit)
14:54:38 web.1 | * Restarting with stat

I’ve realised that editing for example python files in frappe app, the watcher works, but if I edit my custom app, it doesn’t work.

16:05:45 web.1 | * Detected change in ‘/home/frappe/frappe-bench/apps/frappe/frappe/utils/init.py’, reloading
16:05:45 web.1 | * Restarting with stat
16:06:06 web.1 | * Debugger is active!
16:06:06 web.1 | * Debugger PIN: 330-808-860

Thanks

Hi,

Did the watcher works with erpnext apps?
If it is did you install you custom app on current sites?

If I change the erpnext app code, It doesn’t work. Only If I change the frappe app code.
My custom app is installed in the sites.