So you've deployed Urbit on your Linux device but now you want to ensure your Urbit is always running in the background and able to survive restarts. This little guide will show you how to do just that.
Verify Urbit Binary Location
In our case, the Urbit binaries have have been extracted to
/usr/bin/urbit. Yours may be in
/usr/local/bin . You can go to either of those directory, list out the files, and verify if your urbit binary is there. Make sure they are all owned by root, executable, and read-only for group and user (
chown root:root ; chmod 755 ).
Create a Systemd Service
Create a file named
[Unit] Description=Urbit ConditionPathIsDirectory=/home/ubuntu/togtun-pocres// [Service] ExecStart=/usr/bin/urbit -t -p 32323 /home/ubuntu/togtun-pocres// Type=exec User= [Install] WantedBy=multi-user.target
In this example you need to set
ConditionPathIsDirectory to the path of where your Urbit pier folder is. This is the folder that is created where you first ran the Urbit binary from.
ExecStart to the path of where your Urbit binary is followed by any of the Urbit binary parameters. We are setting
-t to disable terminal as this will be running in the background.
-p is set to 32323 which a ames port of our choice. We end this line with the location of our pier folder once again.
Below is a copy of the Urbit man page so you can modify your urbit service as needed.
Save and exit out of
urbit.service file and let's enable/start the service.
With the file modified with your changes we can now enable that file and start it.
systemctl --system daemon-reload systemctl enable --now urbit.service systemctl start --now urbit.service
That's it. Your Urbit should be enabled and started as a service in the background. This means every time your linux devices boots up, Urbit will automatically start. You should be able to reach your Urbit as usual on http://localhost:8080 .
Screen Urbit Systemd Service
If you would like to actually reattach to the urbit binary thats running so you can access dojo, you will need to slightly modify your
urbit.service file. Below are the changes:
[Unit] Description=Urbit ConditionPathIsDirectory=/home/ubuntu/togtun-pocres// [Service] Type=forking Restart=on-failure RestartSec=3 ExecStart=/usr/bin/screen -DmS urbitplanet /usr/bin/urbit -p 34123 /home/ubuntu/togtun-pocres// [Install] WantedBy=multi-user.target
You can see in the
ExecStart line we begin with the screen binary. Then we set
-dmS in which
-Dm allows us to run a command in the screen session and not enter it interactively and
-S lets us give the session a usable name so you can easily reconnect to it later. In our case we named the session
urbitplanet. All of this is followed by our Urbit binary and its parameters.
You can see the status of your
urbit.service by running:
systemctl status urbit.service
Here you can see not only the status of the service but a bit of the log output from the binary being run. If there is any error with the program or parameters you passed, this should be able to give you an idea.
If you have any questions or are interested in receiving a planet, you can contact us on our Urbit group InterestingSoup: ~togtun-pocres/interestingsoup or DM me: ~togtun-pocres.