Use MetaHub headless
I'm new to working with the MetaHub and MetaWear, and I'm working on a project where I need to run the MetaHub headless. Essentially, I want the MetaBase app to start automatically on boot, connect with the Metawear sensors and begin collecting data. I'm seeking guidance in how to configure the MetaHub to have the Metabase app start on boot.
Thanks.
Comments
Use
systemctl
to setup system services.After investigating the systemctl options, I've gone through and created a service file (metabase_boot.service) with the following text:
[Unit]
Description=Launch MetaBase st startup
After=multi-user.target
[Service]
ExecStart=/usr/bin/java /home/pi/Apps/MetaBase/metabase-config.json
[Install]
WantedBy=multi-user.target
I then entered:
sudo systemctl daemon-reload
sudo systemctl enable metabase_boot.service
When I reboot, it doesn't work to launch MetaBase at boot. Any suggestions?
Have you tried running the
ExecStart
command in a terminal?Yes, when I do I get a 'Permission denied' message. Not sure where to go from here.
Looking at the command again, that's not the right command to start MetaBase. Look at the README file on the desktop that explains how to start MetaBase.
No, the command to start MetaBase from the terminal is 'sudo npm start -- --config metabase-config.json'. However, simply substituting what I do have in the .service file for this command doesn't do anything either. I've tried different configurations of the command given in the README file but nothing seems to be working.
I reformatted the service section as follows, but still no success. As I said, I'm very unfamiliar with this type of work, so I could be missing anything.
[Service]
ExecStart=/usr/bin/java --config metabase-config.json
WorkingDirectory=/home/pi/Apps/MetaBase
Check the system logs for any error messages from your service.
The readme does not mention "java" anywhere, not sure why you are calling it.
No, it doesn't but from what I've seen online, it seems I should specify how to read the program. That's why I called 'java'. I will remove it and try again. Do I need to include the all or a portion of the remainder of the terminal command to launch MetaBase (i.e., 'sudo npm start)? I feel as though my issue is in configuring this launch command appropriately.
Follow the example commands in the README. You should at least be comdortable with running MetaBase from the command line.
Yes, I can do that without issue. The issue is in the syntax for the command to launch MetaBase in the .service file. Simply entering 'sudo npm start -- --config metabase-config.json' without the 'ExecStart=' argument does not work. In that case, when I try to enable the .service file, I get the message 'Failed to enable unit: Invalid argument'. Any other configuration with the 'ExecStart=' argument ('ExecStart=sudo npm start -- --config metabase-config.json' or 'ExecStart=--config metabase-config.json' or 'ExecStart=-- --config metabase-config.json') results in the following error message during reboot: 'Executable path is not absolute'. When I call java with the launch command as 'ExecStart=/usr/bin/java --config metabase-config,json', I get no error messages but it still does not appear to work. When I check the output folder, there are no new logs.
So there is your issue. Use absolute paths to the commands.
Yes of course it's not going to work if you use java.