Message Boards Message Boards

GROUPS:

Persistent kernel deployment on Raspberry Pi

Posted 2 months ago
392 Views
|
2 Replies
|
1 Total Likes
|

Hi guys,

This is my first submission on the community so I hope I posted it in the right board.

I have been working on a raspberry pi device that needs to perform run a basic WL script at startup - load packages and call a couple of functions. The "issue" I'm having is that the kernel shuts down at the end of the script and I haven't been able to figure out a better solution to keep it running other than put an infinite loop at the bottom.

directory = "/My/directory/parentfolder/";
SetDirectory[directory];
<<package`;

startFunction[directory];

(* this will keep the evaluation running indefinitely *)

While[
    True,
    (Pause[10];function["heartbeat"])
]

This works but I don't think this is the smartest to do this - definitely not elegant. I am thinking that perhaps creating a super simple front end with wstp may be the way to go, but I have no experience whatsoever with that.

Any thought on this? I appreciate the help.

2 Replies

Are you saying that's in "init.m" ? (ie, ~/.Mathematica/Kernel/init.m) (if so, there are many examples of proper startup modifications for init.m for you to follow).

If not init.m ... If you start mathematica with a WL script it of course exits when done. (your running in batch mode intended to process many files consecutively).

ON THE OTHER HAND if your not (the above), the most usual problem is you have a bug in your script which causes the kernel to Quit[].

Remove the bug, and the kernel won't quit.

Yes many if not most script goofs and script bugs don't cause kernel quits, but some do

ON THE OTHER HAND if you wrote your own "Package" your loading with <<, and getting Quits[] that's another issue. Quits[] are more frequent for loading Packages (intently so). Your package syntax simply must be correct or the package does not load (which may cause a kernel quit as well).

Hi John, thanks for the assist. I am sorry, I should have been more specific.

This is not a package loading issue. The code I posted is part of a wolfram script

startupSequence.wls

which I run on boot every time my device is powered up. My question is exactly how do I keep the kernel from quitting. I understand it quits when reaches the end of the file. In fact, I tried to include

$IgnoreEOF = True

In the script but it did not work (sort of expected it not to, really).

So, my question is: what is the best approach to keep a live kernel running after executing a few simple commands (as in the script)? Is the solution I posted a good one (doesn't seem to me, but, hey, what do I know), or building a simple WSTP program and spinning it up at every boot is really the most reliable way to go?

I appreciate your time and assistance

Best

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract