-
Notifications
You must be signed in to change notification settings - Fork 6
Introducing the hub
To run our first example script, we told the REPL hub run "examples/first.pf"
. That is we ran the script by telling the hub to run the script for us.
But what is "the hub"? If you're coding in Pipefish, it's your new best friend. It allows you to start services and stop them. It helps you write and run tests, it explains error messages for you and traces runtime errors, it lets you turn livecoding on and off, it supplies you with documentation, and if you like it will also turn into a server and perform role-based access management for you. It lets you create, manage, and deploy your scripts and services. It is called "the hub" because it can run several services at once and allows them to interact with one another.
The hub is itself a Pipefish service, but equipped with a few superpowers that makes it the boss of all the other services. However it has the same syntax and semantics as a Pipefish service, because it is one.
Since the hub has so many uses, it has two sections to itself at the end of this wiki. However, to get you started here are some useful instructions:
hub run
As we've seen, hub run "<filename>"
will initialize a service from the given script. The hub will supply a name for the service from the series #0
, #1
, #2
...
If you want to name the service yourself, do hub run "<filename>" as "<service name>"
. E.g:
#0 → hub run "examples/first.pf" as "First"
Starting script 'examples/first.pf' as service 'First'.
First → greet
What's your name? Theophania
Hello Theophania!
First →
hub services
Starting up one service doesn't stop the other services from running. hub services
provides you with a list of all the ones that are.
First → hub services
The hub is running the following services:
▪ Service '#0' running script 'first.pf'.
▪ Service 'First' running script 'first.pf'.
First →
hub switch
hub switch "<service name>"
changes the "current service" (the one you're talking to) to the service named. As you'll have noticed, the name of the current service shows up in the prompt.
First → hub switch "#0"
ok
#0 →
hub halt
hub halt "<service name>"
halts the named service.
#0 → hub halt "First"
ok
#0 →
hub quit
This shuts down Pipefish, but remembers every service you had running at shutdown which you gave a specific name to (by using hub run "<filename>" as "<service name>"
) and starts them up again when you restart Pipefish.
🧿 Pipefish is distributed under the MIT license. Please steal my code and ideas.