Skip to content
This repository was archived by the owner on Mar 21, 2025. It is now read-only.

Commit e059001

Browse files
authored
Allow overriding localhost in default URLs for pslocal (#259)
1 parent 42bd565 commit e059001

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

cmd/pslocal/main.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,17 @@ func initializeFromEmpty(ctx context.Context, server *pslive.Server) error {
6464
if err != nil {
6565
return errors.Wrap(err, "couldn't add default instrument for local planktoscope")
6666
}
67+
localhost := "localhost"
68+
if l := os.Getenv("LOCALHOST_DEFAULT"); l != "" {
69+
localhost = l
70+
}
6771
if _, err = is.AddCamera(ctx, instruments.Camera{
6872
InstrumentID: iid,
6973
Enabled: true,
7074
Name: "preview",
7175
Description: "The picamera preview stream",
7276
Protocol: "mjpeg",
73-
URL: "http://localhost:8000",
77+
URL: fmt.Sprintf("http://%s:8000", localhost),
7478
}); err != nil {
7579
return errors.Wrap(err, "couldn't add default camera for local planktoscope")
7680
}
@@ -80,7 +84,7 @@ func initializeFromEmpty(ctx context.Context, server *pslive.Server) error {
8084
Name: "controller",
8185
Description: "The MQTT control API",
8286
Protocol: "planktoscope-v2.3",
83-
URL: "mqtt://localhost:1883",
87+
URL: fmt.Sprintf("mqtt://%s:1883", localhost),
8488
}
8589
controllerID, err := is.AddController(ctx, controller)
8690
if err != nil {

0 commit comments

Comments
 (0)