Running multiple toit containers with a Global clo...
# help
s
Hi, I would like to ask you how can I run multiple different Toit containers and also have this possibility to put my ESP in deep sleep mode. I want the device wakes up every 20 mins (e.g.) and process different containers and then go to deep sleep mode again. But now i can just have one container with different functions which also has the deep sleep. thanks in advance for your support
f
The easiest would be to use Artemis (https://docs.toit.io/getstarted/fleet). It does this for you. Otherwise there are a few options: - Modify Jaguar so it goes to deep sleep when all containers are done. Jaguar is surprisingly small so that isn't as hard as it sounds. https://github.com/toitlang/jaguar/blob/main/src/jaguar.toit I feel like the biggest challenge would be to install the modified Jaguar. If you have some idea of how to do it it's not hard, but otherwise could be challenging. If you go this route let us know so we can direct you a bit. - Use services to communicate between the individual applications. When an app is done it simply sends a message to the shutdown service. That one then goes to deep sleep when everything is done. Still requires the individual applications to be shutdown aware, though. - Probably others. Unless you need to use open-source, I would try Artemis first, though. If you like tinkering with other programs, then modifying Jaguar could also be fun.
s
Thanks a lot Florian, one question, in Artemis, I also can have multiple containers?
f
yes.
You create a pod-specification that contains all the containers you want. You then say at which interval they should run. Whenever no program needs to run Artemis goes to deep sleep until the next program should run.
This example has two containers in it. The "hello" and "solar" one.
If you need your device to go to deep-sleep you also need to change the "max-offline". If it is 0s, the device will stay awake and continiously request updates from the server.
s
this seems the Artemis is like as docker-compose?
f
there are some ideas from docker 🙂
It's more descriptive.
Docker compose is a bit more imperative. You can write commands one after the other. The pod specification is a description of what should be installed. Things aren't executed in any order.
I think you had a look at Toit v1 at some time. Artemis is the successor to it.
s
perfect, Now I completely understand what is going on, Thanks a lot
I am trying to install Artemis on mac, but I get error: % /Volumes/artemis/artemis ; exit; Error: Missing subcommand.
f
That's a good start.
artemis is a command line application.
You can follow the "getting started" at https://docs.toit.io/getstarted/fleet But fundamentally you now need to: - signup - create an organization - initialize a fleet directory - modify the pod specification - create a pod and install it
s
Actually I followed these steps to sign up and I get the error: zsh: command not found: artemis
I believed I did not install artemis in mac correctly
f
You can always use a relative or absolute path to it.
If you downloaded it you can add it to your path by writing
export PATH=$PATH:$PWD
(assuming you are in the folder that contains
artemis
).
After that you can just write
artemis
and it will find it. At least in the terminal where you wrote
export ...
.
s
thanks I will try this
One more question, I would kindly ask if you update the Jaguar? because two weeks ago when I try to measure energy consumption of my setup while using toit/jaguar was less than today.
f
So Jaguar was using less energy two weeks ago than it is today?
We do update Jaguar regularly, but we don't do anything behind your back.
s
yes,
ok, thanks a lot
f
Usually the biggest energy consumption comes from connecting to WiFi. So maybe it has a harder time connecting to it.
Artemis is generally better for battery operated devices, so I would redo your measurements with it.
s
Excuse me for this basic question, should I export the path of artemis.exe ?
f
After adding the directory of the artemis executable to your
PATH
you should be able to just write
artemis
and the shell will find it.
If you
export
it then sub programs can also see it.
Typically you export it to make things easier.
In both cases it's just a temporary thing, as a new shell would not have the artemis-folder in the
PATH
.
You can make it more permanent by changing your
.zshrc
(I'm assuming you are running
zsh
since you mentioned macOS, and that's the default there)
s
,I export the path of my executable artemis but still i get the error : he error: zsh: command not found: Artemis. , I click on artemis.dmg I get the warning: “artemis” is a Unix app downloaded from the internet. Are you sure you want to open it?
f
The 'dmg' is just a disk image that contains the
artemis
executable.
You should be able to drag&drop the
artemis
file out of the dmg and store it somewhere easier to find.
For example, you could create a
local/bin
directory in your home and copy it there.
then you would have
export PATH=$PATH:$HOME/local/bin
Apparently you should just drap the dmg into your "applications" folder.
(just learned that).
(but we are still investigating. We are just very used to modifying the
PATH
so we aren't too familiar with the typical macos flow).
After looking more, it seems like
applications
isn't actually a good place for it. So putting it into
local/bin
in your home is probably the best.
We will see if we can get a
brew
setup working. That would make things easier to install.
s
ok thanks a lot I will try thi sapproach
I would like to ask you a question as I could not install artemis on mac. I tried to install on linux and I add the path to Artemis to my path. but after running this command "artemis auth login" I get thi serror: GLBC_2.29 not found (required by artemis)it
f
usually that means that your Linux is not up to date.
It could be that we are compiling on a Linux that is too recent.
Let me check what version we require.
We are using the latest Ubuntu.
I will change it to something older.
Give me a few minutes and I will upload you an Artemis version that hopefully works with your system.
After a second look, it looks like we are already using Ubuntu 20.04 to build. Is your system older than that?
If you want to try again on macos, here are the commands I would use:
Copy code
cd /tmp
curl -L -O https://github.com/toitware/artemis-releases/releases/download/v0.6.2/artemis-macos.zip
unzip artemis-macos.zip
chmod +x artemis
mkdir -p $HOME/local/bin
mv artemis $HOME/local/bin
export PATH=$PATH:$HOME/local/bin
cd $HOME
artemis --version
If you are running the zsh. (You can check by running
ps -p $$
) you can change the PATH for future sessions by running the following command:
Copy code
echo "PATH=$PATH:$HOME/local/bin" >> $HOME/.zshrc
You can use chat.openai.com to get a pretty decent description of what each of these commands is doing.
I asked chat.openai.com of whether these commands should work on macos, and it claims that
unzip
might not be available directly or not have all the necessary features. If you have difficulties with
unzip
you can either try to install a better version with
brew install unzip
(assuming you have
brew
installed), or simply unzip the archive by hand.
s
It works, thanks a lot,
Thanks for the hint, further I will first ask chat.openai.com.
f
It's not perfect (and often hallucinates/lies), but for these kind of things it's a good help.
b
The method that works for me, is to open the. dmg file, then in a terminal, type:
cp /Volumes/artemis/artemis /Applications