<p>Hello, I am working on a app which consists of a UI and this "detached" daemon running on a raspberry pi.
I want the daemon to be controlled remotely.
To achieve this I thought of:</p>
<ul>
<li>API that will be polled every once in a while to know what the daemon has to do</li>
<li>The daemon should be running forever and call the api/execute the instructions</li>
</ul>
<p>Does this make sense? How can I build something like this in go? Does it make sense to have a forever-running daemon or should I have a cron entry that triggers the program?</p>
<p>Is it possible to have a cli through which you can retrieve the command, and then run another go program that executes this command?</p>
<p>What can I research? How do you design this kind of stuff?</p>
<hr/>**评论:**<br/><br/>slabgorb: <pre><p>This may be helpful for this scenario: <a href="https://golang.org/pkg/net/rpc/" rel="nofollow">https://golang.org/pkg/net/rpc/</a></p></pre>ask: <pre><p>What the thing does, how often it talks and what other constraints or requirements you have makes a difference for what the right answer is.</p>
<p>It sounds like you are just starting out though, so ... just get typing and try it out. It can work and if it's not quite the right solution in the end, you'll for sure have learned a bunch and will have some empirical experience to apply next time you are trying to match a solution to your problem.</p></pre>LC2712: <pre><p>Hi, how often it talks really depends. The ideal scenario is to have a node (for example) app sending commands (json) to the remote raspberry pi, so it doesn't have to check itself.
It might be the case to have a socket, but not sure.</p></pre>