OctoPrint using Multiple Printers

With the release of OctoPrint 1.3.9 came new 'oppotunities'.

A simple upgrade from 1.3.8 didn't go so well.

I ended up re-installing OctoPrint from scratch - which was fine, as it doesn't take much to get it going - or so I thought.

To get 2 instances of OctoPrint 1.3.8 running on my Raspberry Pi I originally used an article I found called 'Setting up OctoPrint on a Raspberry Pi for multiple printers'.

For whatever reason, after installing a fresh version of OctoPrint 1.3.8 with OctoPi 0.15 the above instructions didn't work out so well.

After a loooot of troubleshooting I found that most of my problems were with HAProxy - and still are. But as with everything, there is usually a useful workaround that fits the bill.

With OctoPrint 1.3.8 and OctoPi 0.15 I ended up finding another article 'Using multiple 3D Printers with a single Raspberry Pi and OctoPrint.

This article is great because it takes care of the editing of files etc for you.

But.... I still had issues with HAProxy.

The HAProxy configuration (/etc/haproxy/haproxy.cfg) that I got working was the following:

global
        maxconn 4096
        user haproxy
        group haproxy
        log 127.0.0.1 local1 debug

defaults
        log     global
        mode    http
        option  httplog
        option  dontlognull
        retries 3
        option redispatch
        option http-server-close
        option forwardfor
        maxconn 2000
        timeout connect 5s
        timeout client  15min
        timeout server  15min

frontend public
        bind *:80
        bind 0.0.0.0:443 ssl crt /etc/ssl/snakeoil.pem
        option forwardfor except 127.0.0.1

        use_backend webcam if { path_beg /webcam/ }
        use_backend mindy if { path_beg /mindy/ }
        use_backend mork if { path_beg /mork/ }
        default_backend webcam

backend mork
        reqrep ^([^\ :]*)\ /mork/(.*) \1\ /\2
        option forwardfor
        server octoprint1 127.0.0.1:5000
        acl needs_scheme req.hdr_cnt(X-Scheme) eq 0
        reqadd X-Scheme:\ https if needs_scheme { ssl_fc }
        reqadd X-Scheme:\ http if needs_scheme !{ ssl_fc }
        reqadd X-Script-Name:\ /mork

backend mindy
        reqrep ^([^\ :]*)\ /mindy/(.*) \1\ /\2
        option forwardfor
        server octoprint1 127.0.0.1:5001
        acl needs_scheme req.hdr_cnt(X-Scheme) eq 0
        reqadd X-Scheme:\ https if needs_scheme { ssl_fc }
        reqadd X-Scheme:\ http if needs_scheme !{ ssl_fc }
        reqadd X-Script-Name:\ /mindy

backend webcam
        reqrep ^([^\ :]*)\ /webcam/(.*)     \1\ /\2
        server webcam1  127.0.0.1:8080
        errorfile 503 /etc/haproxy/errors/503-no-webcam.http

Once you restart your server you should now see that everything works.... Yay!

Well.. yay... until I tried to install Plugins through the Plugin Manager.

After installing the plugins in Mork, they would appear. When installing them in Mindy, they would not appear. The Plugin Manager showed that they were installed though.

To troubleshoot, I first stopped haproxy (sudo service haproxy stop). I then loaded up Mindy using port 5001 and voila! The plugins worked.

I then started haproxy (sudo service haproxy start), and the plugins still worked.

I have just got to this point and I haven't done much more testing than this. I wanted to document it before I forgot.

I hope that this helps you out.