Docs updates in passing.

This commit is contained in:
Robin Davies
2024-11-11 20:56:52 -05:00
parent 64062fbbd7
commit c4fd810d06
3 changed files with 120 additions and 76 deletions
+9
View File
@@ -52,6 +52,15 @@ Run the following command to install and configure React dependencies.
cd ~/src/pipedal
./react-config # Configure React NPM dependencies.
And one final step. Edit the file `/etc/sysctl.conf`, and add or increase the value for the maximum number of watchable user
files:
fs.inotify.max_user_watches=524288
Then run `sudo sysctl -p` to get the change to take effect. Visual Studio Code and the React Debug server both need this
setting to run properly. Older versions of Raspberry Pi OS set this value too low; and I am not honestly sure whether current
versions of Raspberry Pi OS have fixed the problem.
--------------------------
[<< Building PiPedal from Source](BuildingPiPedalFromSource.md) | [Up](Documentation.md) | [The Build System >>](TheBuildSystem.md)
+6 -2
View File
@@ -5,11 +5,15 @@ page_icon: img/Compiling.jpg
{% include pageIcon.html %}
PiPedal has only been tested on Raspberry Pi OS, and Ubuntu, but should run with little or no modification on most Linux distributions. Pull requests to correct problems with building PiPedal on other versions of Linux are welcome.
PiPedal has only been tested on Raspberry Pi OS, and Ubuntu, but should run with some modifications on most Linux distributions. Pull requests to correct problems with building PiPedal on other versions of Linux are welcome. However, getting build pre-requisites installed on non-Debian-derived Linux distrubutions (distros that don't use `apt`) will be challenging.
To build and debug PiPedal using Visual Studio Code, you need 8GB of memory. You can build PiPedal with 2GB of memory.
You should also be able to cross-compile PiPedal easily enough, but we do not currently provide support on how to do this. Visual Studio Code provides excellent support for cross-compiling, and good support for remote and cross-platform debugging, all of which should work with the PiPedal CMake build. However, management of ARM pakages on a Windows machine when cross-compiling is not great. Remote debugging may be a better path.
If your Pi is short on memory, you _can_ run VSCode on laptop or desktop and configure VSCode to connect to your Raspberry PI using SSH connections. You can definitely build PiPedal using remote SSH connections on a 6GB Ubnutu VM; and can probably build Pipedal using SSH connections on a 4GB Raspberry Pi, as long as you are careful.
As a last resort, you be able to configure VSCode and/or CMake to crosss-compile PiPedal on a laptop or desktop computer; but installing build dependencies when cross-compiling will be extremely challenging. This is not a scenario that we can provide support for.
--------
[<< Which LV2 Plugins Does PiPedal Support?](WhichLv2PluginsAreSupported.md) | [Up](Documentation.md) | [Build Prerequisites >>](BuildPrerequisites.md)
+105 -74
View File
@@ -31,115 +31,117 @@ or
pipedalconfig -stop #Stops the Jack service as well.
But there's no harm in running a debug react server that's configured to connect to the web
socket of a production instance of pipedald on port 80, if you aren't planning to debug C++ code.
Although not strictly neccesary, you should probably add your login account to the pipedal_d group.
sudo usermod -a -G pipedal_d *youruserid*
This will allow you to run `pipedald` under the debugger of your choice using the
same /etc/pipedal and /var/pipedal directories as an instance of `pipedal` running
under systemd. Note that when running under systemd, `pipedald` runs under an unprivileged
`piedal_d` service account, and relies it's group (also 'pipedal_d`) in order to access its
data files, and to communicate with the `pipedaladmin` service, which does run with root
priveleges when `pipedald` needs to perform operations that do required root privileges.
For what it's worth, `pipedaldmin` is virtually undebuggable, becuase it does require root privileges to run.
If you really _must_ debug pipedaladmin, you can fire up a sudo isntance of Visual Studio Code
and attach to the running daemon process. But running program as large as VS Code with root privileges
is a dangerous process, that VS Code firmly (and righfully) complains about. And configuring
VSCode to run with root privileges as a painful process. Avoid if you can.
The pipedald service will run with or without the pipedaladmind service, but some operations (shutdown, reboot,
audio and Wi-Fi configuration changes) may fail if the pipedaladmind service is not running.
audio and Wi-Fi configuration changes) may fail if the pipedaladmind service is not running. Pipedal communicates
with pipedaladmin via Unix docket that can only be opened by members of the pipedal_d group. So if you have
added your own account to the `pipedal_d` group, debug instances of `pipedald` will in fact work properly.
In production, the pipedald web server serves the PiPedal web socket, as well as static HTML from the built
react components. But while debugging, it is much more convenient to use the React debug server for
React sources, and configure pipedald to serve only the websocket.
Note that a debug instance of `pipedald` cannot bind to port 80, since that requires either root privileges or
access to port 80 via `authd`. So you will have to configure the debug isntance of `pipedald`'s web server to
bind to port 8080 instead. The react server will serve the web applicaton on port 3000, so you will point your web
browser to `raspberrpi:3000`. And you will then need to configure the react application to make web socket
connection on port 8080 (where pipedald provides all dynamic content in the web app).
You may find it convenient to reconfigure the systemd intances of `pipedald` to bind to port 8080 as well.
That will allow the react server to point clients to either a debug instance or the systemd instance of `pipedald`
depending, depending on which instance of pipedald is currently running. Run the following command to
make the systemd instance of `pipedald` bind to port 8080 instead of port 80:
pipedalconfig --install --port 8080
(which will also restart the `pipedald` service).
To start the React debug server, from a shell, `cd` to the react directory, and run `./start`. The react debug
server will detect any changes to React sources, and rebuild them automatically (no build step required).
Actual debugging is performed using the Chrome debugger (which is remarkably well integrated with React).
To get this to work on Raspberry Pi, you will probably have to make a configuration change.
Edit the file `/etc/sysctl.conf`, and add or increase the value for the maximum number of watchable user
files:
fs.inotify.max_user_watches=524288
followed by `sudo sysctl -p`. Note that VS Code and the React framework both need this change.
Actual debugging is performed using the Chrome debugger (which is remarkably well integrated with React).
You won't actually see changes to the version of the systemd version of the static web app until you
do a full _Release_ or _RelWithDebInfo_ build of PiPedal, followed by running `./install.sh` which pushes
the built react app in the location where the systemd version of `pipedald` serves static web content.
By default, the debug React app will attempt to contact the pipedald server on ws:*:8080 -- the address on which
the debug version of pipedald listens on. This can be reconfigured
in the file `react/src/public/var/config.json` if desired. If you connect to the the pipedald server port, pipedald intercepts requests for this file and points the react app at itself, so the file has no effect when running in production.
the debug version of pipedald listens on. This can be reconfigured
in the file `react/src/public/var/config.json` if desired. If you connect to the the pipedald server port (port 80), pipedald intercepts requests for this file and points the react app at itself, so the file has no effect when running in production.
The React app will display the message "Error: Failed to connect to the server", until you start the pipedald websocket server in the VSCode debugger. It's quite reasonable to point the react debug app at a production instance of the pipedald server instead.
The React app will display the message "Error: Failed to connect to the server", until you start the pipedald websocket server in the VSCode debugger. However, it's quite reasonable to point the react debug app at a systemd instance of the pipedald server instead, if you don't intend to debug C++ code.
react/public/var/config.json:
{
...
"socket_server_port": 80,
"socket_server_port": 8080, # (PiPedald's port number)
"socket_server_address": "*",
...
}
Setting socket_server_address to "*" configures the web app to using the host address of the current
web page. If you set it to a specific address, the web app will attempt to establish a websocket connection
son that specific address instead. (Not sure what that's useful for, but it's there if you ever need it).
Setting socket_server_address to "*" configures Browers clients to make web socket connections on the same
IP address they used to load the web app in the first place. If you set it to a specific address, the web app
will attempt to establish a websocket connection son that specific address instead. (Not sure what that's useful
for, but it's there if you ever need it). When running under systemd, Pipedal usually redirects browser clients
to an IPv4 address if the initial connection was made via IPv6, since long-lasting IPv6 websocket connections
are problematic, and IPv6 link-local adresses (which you sometimes get from mDNS servers) are completely toxic.
The React debug server does not do that (since the app configuration that clients get from the
React server is static). If you're connecting using mDNS (via 'raspberrypi:3000', for example), you could
end up connectiong to the React web app on an IPv6 address. So it might be useful for that. The easier solution
is probably just to use an explicit IPv4 address when you connect to the React debug server.
The original development for this app was done with Visual Studio Code. Open the root project directory in
Visual Studio Code, and it will detect the CMake build files, and configure itself appropriately. Wait for
the CMake plugin in Visual Studio Code to configure itself, after loading.
The original development for this app was done with Visual Studio Code. And it's probably easiest to go with the flow when building
or debugging PiPedal. Open the root project directory in Visual Studio Code, and VSCode will automatically detect the CMake build
files, and configure itself appropriately. It usually takes VSCode about 20 or 30 seconds to completely configure itself for a CMake project
and to settle down a bit.
Once CMake has configured itself, build and debug commands are available on the CMake toolbar at the
bottom of the Visual Studio Code window. Set the build variant to debug. Set the debug target to "pipedald".
Click on the Build button to build the app. Click on the Debug button to launch a debugger.
Once VSCode has configured itself, build and debug commands are available on the CMake toolbar at the
bottom of the Visual Studio Code window. (Or in the CMake tab on the left-hand side of VSCOde if you have
chosen not to configure the CMake add-on to make CMake controls visible on the bottom toolbar).
Choose your compiler toolset. PipPedald sort of builds on a Clang toolset; although Clang may give warnings. But it's usually
not significantly worse than building on a newly released version fo GCC. It's probably best to do your first build with the build
variant set to RelWithDebugInfo. If you can get to the point that you can install Pipedal using ./install.sh, then that will
ensure that all the various configuration files that Pipedal requires are deployed in all the right places, whether the services
run properly or not. Check system logs using `journalctl -b0 | less` to see how well your newly built version of
Pipedal is doing, and stop systemd services as neccesary and appropriate.
Set the build variant to debug. Set the debug target to "pipedald". Click on the Build button to build the app. Click on the Debug button to launch a debugger.
To get the debugger to launch and run correctly, you will need to set command-line parameters for pipedald.
Command-line arguments can be set in the file `.vscode/launch.json`:
{
...
"cmake.debugConfig": {
"args": [
"<projectdirectory>/debugConfig",
"<projectdirectory>/build/react/src/build",
"-port",
"0.0.0.0:8080"
],
...
}
where `<projectdirectory>` is the root directory of the pipedal project.
The default debug configuration for pipedal is configured to use /var/pipedal for storing working data files,
which allows it to share configuration with a production instance of pipedal. Be warned that the permissioning
for this folder is intricate. If you plan to use the data from a production server, get the production server
installed first so the permissions are set correctly.
If you install a production instance later, remove the entire directory before doing so, to ensure that none
of the files in that directory are permissioned incorrectly.
You will need to add your userid to the pipedal_d group if you plan to share the /var/pipedal directory.
sudo usermod -a -G pipedal_d *youruserid*
You will need to reboot your machine to get the group membership change to take effect,or log out and log back
in if you can do that.
To run pipedald in a debugger, you need to use the following command-line to launch pipedal:
build/src/pipedald /etc/pipedal/config /etc/pipedal/react -port 0.0.0.0:8080
The first argument specifies where the pipedal daemon's configuration files are. The second argument specifies where
built static web pages for the web application are. And the port option specifies the port on which the daemon will
listen. If you are using a React debug server to serve up the web appliation you will point your browser at the
React debug server on port 3000; but the web application will still need to connect to web sockets on the 8080 port.
If you are using Visual Studio Code, you might find it useful to add the following section to your `.vscode/launch.json` file:
{
...
{
{
"name": "(gdb) pipedald",
"type": "cppdbg",
"request": "launch",
// Resolved by CMake Tools:
"program": "${command:cmake.launchTargetPath}",
"args": [ "/etc/pipedal/config", "/etc/pipedal/react", "-port", "0.0.0.0:8080" ],
"args": [ "/etc/pipedal/config", "/etc/pipedal/react", "-port", "0.0.0.0:8080", "-log-level","debug" ],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [
{
// add the directory where our target was built to the PATHs
// it gets resolved by CMake Tools:
"name": "PATH",
"value": "$PATH:${command:cmake.launchTargetDirectory}"
},
{
"name": "LD_LIBRARY_PATH",
"value": "/usr/local/lib/aarch64-linux-gnu"
}
],
"externalConsole": false,
@@ -152,8 +154,37 @@ If you are using Visual Studio Code, you might find it useful to add the followi
}
]
},
...
}
You must then set `pipedald` as the debug target on the CMake toolbar, AND configure the VSCode debugger
to use the `(gdb) pipedald` debug configuration. Click on the VSCode Debug tag on the left-hand side of the VSCode
window, and select the debug configuration using the dropdown found at the top edge of the Debug tab.
The recommended way to debug `pipedald` is to point it at the `/etc/pipedal` and `/var/pipedal` directories
that the live systemd version of `pipedald` uses. It is theoretically possible to get a debug instance to use
a completely separate set of directories; but setting up the initial files and folders created by the PiPedal
is complicated; and I have done that personally in a very long time.
You will need to add your userid to the pipedal_d group if you plan to share the /var/pipedal directory.
sudo usermod -a -G pipedal_d *youruserid*
And you will need to reboot your machine to get the group membership change to take effect,or log out and log back
in if you can do that.
To debug the React app, use Chrome debugging tools. Load the PiPedal web app, and then press F12 in Chrome. You can
then set breakpoints in PiPedal's Typescript source (visible on the Source Tab of the Chrome Debugger). Chrome provides
very capable and functional debugging of Typescript right in the browser.
There is a chrome add-on for debugging React apps; you may need to install the add-on in Chrome to get all of
this to happen properly.
Having gone through a huge amount of work to get this point, let it be known that the Pipedal project is
very receptive to accepting push request to its Github repository. So, if you have fixes, or changes, or enhancements
to a PiPedal fork, feel free to push them back to the main repository. The best way to do this is to create a branch on
your personal fork of PiPedal, and make a pull request against the main PiPedal Github repository. Keeping your pushed changes
on a branch in your fork allows us to go back and forth a bit on proposed changes without making a mess of your fork.
-----