Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
notes on how to multiply klipper-instances (and moonraker) to have a multi-printer setup using https://github.com/cadriel/Fluidd (and/or https://github.com/cadriel/FluiddPI)
# https://gist.github.com/gretel/3c48280e29b03e596a8156f3215ebdb8
### service startup for klipper instance 2
sudo cp /etc/default/klipper /etc/default/klipper-2
sudo vi /etc/default/klipper-2
# KLIPPY_ARGS="/home/pi/klipper/klippy/klippy.py /home/pi/klipper-2_config/printer.cfg -l /tmp/klippy-2.log -a /tmp/klippy-2_uds -I /tmp/printer-2"
sudo cp /etc/init.d/klipper /etc/init.d/klipper-2
sudo vi /etc/init.d/klipper-2
# DESC="klipper-2 daemon"
# NAME="klipper-2"
# DEFAULTS_FILE=/etc/default/klipper-2
# PIDFILE=/var/run/klipper-2.pid
### service startup for moonraker instance 2
sudo cp /etc/systemd/system/moonraker.service /etc/systemd/system/moonraker-2.service
sudo vi /etc/systemd/system/moonraker-2.service
# Description=Starts Moonraker-2 on startup
# ExecStart=/home/pi/moonraker-env/bin/python /home/pi/moonraker/moonraker/moonraker.py -l /tmp/moonraker-2.log -c /home/pi/klipper-2_config/moonraker.conf
### copy existing configuration over. please tidy up accordingly
cp -rv /home/pi/klipper_config /home/pi/klipper-2_config
### unique moonraker socket
vi /home/pi/klipper-2_config/moonraker.conf
# port: 7126
# config_path: /home/pi/klipper-2_config/klipper-2_config
# klippy_uds_address: /tmp/klippy-2_uds
### unique moonraker serial port
vi /home/pi/klipper-2_config/printer.cfg
# [mcu]
# serial: /dev/serial/by-id/usb-1a86_USB_Serial-if00-port0 # :)
### adjust 'cors' configuration for all endpoints
vi /home/pi/fluidd/config.json
# "endpoints": [
# "http://fluiddpi",
# "http://fluiddpi.local",
# "http://fluiddpi.local:7125",
# "http://fluiddpi.local:7126"
# ],
### now that the files are changed let the daemon read them in
sudo systemctl daemon-reload
### enable start on bootup
sudo systemctl enable klipper-2
sudo systemctl enable moonraker-2
### and execute!
sudo systemctl start klipper-2
sudo systemctl start moonraker-2
@jasonhamilton
Copy link

jasonhamilton commented Oct 13, 2021

Thanks for this @gretel! I'm running MainsailOS which uses systemd for managing services. In case anyone needs it, I'll leave my notes here...

Klipper Setup

### service startup for klipper instance 2
sudo cp /etc/systemd/system/klipper.service /etc/systemd/system/klipper2.service
sudo vi /etc/systemd/system/klipper2.service
# Before=moonraker2.service
# Alias=klippy2
# Environment=KLIPPER_CONFIG=/home/pi/klipper_config/printer2.cfg
# Environment=KLIPPER_LOG=/home/pi/klipper_logs/klippy2.log
# Environment=KLIPPER_SOCKET=/tmp/klippy2_uds

### copy existing configuration over. please tidy up accordingly
cp -v /home/pi/klipper_config/printer.cfg /home/pi/klipper_config/printer2.cfg

### update unique mcu serial port in printer config
vi /home/pi/klipper_config/printer2.cfg
# serial: YOUR_UNIQUE_SERIAL_PORT

### start service
sudo systemctl enable klipper2.service
sudo systemctl start klipper2

### verify service is running and no errors in logs
service klipper2 status
tail /home/pi/klipper_logs/klippy2.log

Moonraker Setup

### service startup for moonraker instance 2
sudo cp /etc/systemd/system/moonraker.service /etc/systemd/system/moonraker2.service
sudo vi /etc/systemd/system/moonraker2.service
#Environment=MOONRAKER_CONFIG=/home/pi/klipper_config/moonraker2.conf
#Environment=MOONRAKER_LOG=/home/pi/klipper_logs/moonraker2.log

### copy existing configuration over.
cp -v /home/pi/klipper_config/moonraker.conf /home/pi/klipper_config/moonraker2.conf

### update settings for service
vi /home/pi/klipper_config/moonraker2.conf
# port: 7126
# klippy_uds_address: /tmp/klippy2_uds

### enable service
sudo systemctl enable moonraker2.service
sudo systemctl start moonraker2

### verify service is running and no errors in logs
service moonraker2 status
tail /home/pi/klipper_logs/moonraker2.log

@thepwnshop
Copy link

thepwnshop commented Apr 13, 2022

Followed the above instructions for Mainsail. Unfortunately, something is not right. The service starts, but there is no moonraker2.log file.
I can access my first printer that was already configured, but the second one does not work.

@gretel
Copy link
Author

gretel commented Apr 13, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment