Skip to content

Commit

Permalink
Add the multiinstance doc
Browse files Browse the repository at this point in the history
  • Loading branch information
TojikCZ authored and ondratu committed Aug 29, 2023
1 parent 7db47ee commit e0db814
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 2 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

0.7.1rc2
* Add an automatic PrusaLink image builder script
* Add multi-instance documentation

0.7.1rc1 (2023-08-10)
* Fixed HTTP response status on HEAD request for non-existing files
Expand Down
77 changes: 77 additions & 0 deletions MULTIINSTANCE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# PrusaLink multi instance
In this mode, an instance of PrusaLink is created for each new printer
detected on any of the USB ports of the host system, allowing the user
to connect multiple printers using a single Raspberry Pi.

## Setup
The multi instance image requires the same setup as the regular one,
but there are some differences

1) The multi-instance manager does not connect to printers on the GPIO
pins as the device udev auto-detection in Linux does not work on those
2) Cameras automatically connect to the first instance only. If you wish
to use for example a camera for each printer, you'll need to manually
copy over relevant configuration
3) In this image, the manager of these PrusaLink instances is run as root.
However web interface of the instance manager is run under the user account.

### Cameras
The temporary process of connecting multiple cameras is not user friendly
and requires manual work. This will change in the future.
The process is as follows:
1) Connect all cameras you wish to use and let them connect to the first
instance
2) Open the web interface of the first instance and under cameras, save
every camera manually. This will create a configuration section for each
camera in `prusa_printer_settings.ini` of the first instance
3) Using ssh, navigate to `/etc/prusalink/prusalink1.ini` and open it
4) Turn off the camera auto-detection in the first instance by adding
this section into the file
```
[cameras]
auto_detect = False
```
5) Navigate to `/home/<username>/PrusaLink1` and open
`prusa_printer_settings.ini`
6) Move the section corresponding to each camera over to the instance in which
you wish to use it. The camera sections have hashes as names,
the order of which is noted in the section `[camera_order]`
7) Move the camera order entry for each camera as well.
A camera order section with a single camera in it looks like this
```
[camera_order]
1 = asdfghjkl
```
8) After a reboot, the cameras should be connected to the correct instances

## Running the manager
To run PrusaLink in the multi-instance mode run `prusalink-manager start`
as root. There are other options allowing you to specify which user to run the
instances and web under. The default is UID = 1000

Here's the help output of prusalink-manager

```
Multi-instance suite for PrusaLink
positional arguments:
{start,stop,clean,rescan}
Available commands
start Start the instance managing daemon (needs root
privileges)
stop Stop any manager daemon running (needs root
privileges)
clean Danger! cleans all PrusaLink multi-instance
configuration
rescan Notify the daemon a printer has been connected
options:
-h, --help show this help message and exit
-i, --info include log messages up to the INFO level
-d, --debug include log messages up to the INFO level
-u USERNAME, --username USERNAME
Which users to use for running and storing everything
-p PREPEND_EXECUTABLES_WITH, --prepend-executables-with PREPEND_EXECUTABLES_WITH
Environment variables and path to the executables
directory
```
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ similar redirect on the loopback interface
iptables -t nat -I OUTPUT -p tcp -o <loopback device name> -d localhost --dport 80 -j REDIRECT --to-ports 8080
```

### Multi-instance
If you want to connect multiple printers to a single pi, have a look at
[MULTIINSTANCE.md](MULTIINSTANCE.md)

## Usage
By default, the executable starts the daemon process and exits.
The executable is called `prusalink` and can be used to control the daemon,
Expand Down
4 changes: 2 additions & 2 deletions prusa/link/multi_instance/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def main():
"""The main function for the PrusaLink instance manager.
Parses command-line arguments and runs the instance controller"""
parser = argparse.ArgumentParser(
description="Multi instance suite for PrusaLink")
description="Multi-instance suite for PrusaLink")

parser.add_argument("-i",
"--info",
Expand Down Expand Up @@ -255,7 +255,7 @@ def main():

subparsers.add_parser(
"clean",
help="Danger! cleans all PrusaLink multi instance configuration")
help="Danger! cleans all PrusaLink multi-instance configuration")

# Create a subparser for the printer_connected command
subparsers.add_parser(
Expand Down

0 comments on commit e0db814

Please sign in to comment.