Multiple instances, do i need Docker?

What is the problem?

I use octoprint for my first time. i got my orange pie and installed python and octoprint on it, without docker, yesterday.
Now i want to use multiple instances of octoprint, because i have two printers.
Do i need to use docker?

What did you already try to solve it?

i searched a lot of tutorial in the web. Most of it use docker for it.
Really important should be the udev_rules, because each printer need a specific identifing

Now i found a other tutorial, which not use docker! So i would prefer this one......

when the tutorial is correct, i only need to copy the folder and fix the config.yaml file. It would be great,
BUT I DON'T have a config.yam file in my directory.

The yaml file is in another directory:

Which directory do i need to copy?

or both of them??

but how can i setup my second OctoPrint to use the other config.yaml file?

So i found this site:

Is it correct, that i can ceate a config.yaml file and octoprint will use it, when i start it again?
I found a part, where i can choose the port. so i would use different ports for eac octoprint directory

The problem with the usb-connection:
i found a part in the config.yaml for serial
can i use there my symlink? for e.g.

  # Use the following option to define the default serial port, defaults to unset (= AUTO)
  port:/dev/mySymLink:/dev/ttyACM0  \

EDIT: since i wrote this pot i tried to copy both directories.

home/user/OctoPrint/ --> home/user/OctoPrint2/
home/user/.octoprint/ --> home/user/.octoprint2/

with the command line

~/OctoPrint2/venv/bin/octoprint serve --basedir ~/.octoprint2


~/OctoPrint/venv/bin/octoprint serve --basedir ~/.octoprint

the terminal window freeze by

2024-02-05 02:14:32,445 - octoprint.server.heartbeat - INFO - Server heartbeat <3

is it normal?

i set different ports, in each yaml file

Thank you for your help

I would highly recommend that you use the octoprint_deploy script linked from the download page to setup multiple instances.

looks really good!!!

at this moment, it work with my solution too....
i copy the config directory ".octoprint" and the "OctoPrint" directory.
than i use this command to set the config directory to each instance.

octoprint serve --basedir ~/.octoprint2/

it works fine.
i can run each instance alone or all together. should i try to remove all and use the script from you?

That's in essence what the deploy script does, so if you already have it working keep it that way.

Just be careful when you connect printers. OctoPrint will always grab the first printer, often even if it is already connected to your other instance. That can lead to bad, or at the least, confusing things. This is one of the things octoprint_deploy solves, as the instances are "registered" with udev rules to the specific printer you are using.

Thank you
i did it with udev rules.

really cool.. that octoprint_deploy can creat it automatically

i got the usb-connection infos of each printer and set symlinks.

in the different config.yaml files i create the new serial connection by the symlink and set it as default...

was not so easy..... :face_with_peeking_eye:

ANOTHER QUESTION about pyhton pip

When i run my second instance of octoprint and i will install a plugin, it use the pip frome the other instance:

Installiere Plugin "OctoPrint-PrettyGCode" von
/home/octoprint/OctoPrint/venv/bin/python3 -m pip --disable-pip-version-check install file:///tmp/tmp9t1wt7vs/ --no-cache-dir

BUT it should be a other directory

/home/octoprint/OctoPrint2/venv/bin/python3 -m pip --disable-pip-version-check install file:///tmp/tmp9t1wt7vs/ --no-cache-dir

can i set the path to the pip file in the yaml file?
i found:
localPipCommand: None

It should use the pip from the same place that OctoPrint is installed. If you have different virtual environments for each instance, you have to install OctoPrint in each one, and serve it from there. Are you definitely serving OctoPrint from separate environments?

i had install one venv. This is located in "octoprint/venv/bin/..."
after this, i had copy the "octoprint" directory and the ".octoprint" directory.

So i have currently

  1. The directory "octoprint" which use the config.yaml file in ".octoprint"
  2. The directory "octoprint2" wich use the config.yaml file in ".octoprint2"

the ".octoprint/config.yaml" use the port 5000
the ".octoprint2/config.yaml" use the port 5002

this is technically unnecessary. you can run the same venv and just have the command line point to the other basedir (.octoprint2) for the second instance.

I run the second instance with path/octoprint2/venv/bin/octoprint serve --basedir .octoprint2

It works. It would be use the config.yaml from this directory.
But pip would be use from the other directory octoprint1 :frowning:

this is my service code

ExecStart=/home/octoprint/OctoPrint2/venv/bin/octoprint serve --basedir /home/octoprint/.octoprint2

but it will start the pip from the other directory

has somebody any idea?

Instead of copying the virtual environment, have you tried creating two of them independently? I think it should be possible to copy them & move them, but there is most likely reference in the venv/bin/octoprint binary to everything still being in the old location, so its probably actually running out of the original location.

oh.. that's a good idea!

i had a look in the octoprint file
this is the code in the file

# -*- coding: utf-8 -*-
import re
import sys
from octoprint import main
if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])

now i need to change the path in the other octoprint file
i need this path

# -*- coding: utf-8 -*-
import re
import sys
from octoprint import main
if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])

but the path is only a comment

It's a comment, but it does matter here - because it's executable, it designates what runtime environment the file will be executed with.

1 Like

thats mean, i can change here the path and it should be work?

i need to change all files in ".octorprint" and change the path....
now it works at the moment.
thank you

1 Like

I used the script and I can access both of my printers individually but Cura only lets me have one connected at a time. Is that normal? When I connect printer 1, printer 2 disconnects and so forth.

might make sense for you to open your own post asking for help. pretty sure you have to create separate printer profiles for each instance individually. I have two separate machines with each having their own connection settings.