This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Abdiel's profile picture

Auto-updating system

Started by Abdiel, 07 December 2012 - 08:52 PM
Abdiel #1
Posted 07 December 2012 - 09:52 PM
Greetings!

New to the forums, been playing with CC for about a month (loving the mod). I've been a professional programmer for 1.5 years and studying CS at a university for over 5 - so coding is nothing new to me. Feel free to use "big words" in your replies - I know what I'm doing (most of the time).

I am working on a distributed system involving dozens, up to maybe a hundred cooperating turtles. (I'm only going to say, a replacement for Logistic Pipes for SMP. If it ever approaches anything close to useable, I might post it here.) Currently, every turtle in the system carries several (currently 5-6) programs that the system uses. For a while now I have been wondering about how to handle system updates. While I'm testing things in SSP I got used to simply putting all of the files in the /rom/ folder, which is obviously impossible on SMP. And running around derping with a disk drive doesn't sound like my idea of fun.

I know of the pastebin program, and HTTP is enabled on my server, so I can use it. The system has one "Terminal" node which a user uses to interact with the system. From a user standpoint, I would love updating everything (every turtle in the system) to be as simple as typing an update command into the terminal. I already have the architecture to send this command to every node in the system.

However the problem is, every time I change the contents of a pastebin file, its address changes. So I can't just keep a hardcoded list of addresses for all the necessary files. I don't think there is any way to derive the "new" link from the "old" link (other than well parsing the pastebin webpage, which seems a bit overkill). Unless there is some undocumented feature of the pastebin program that I don't know about. The best I've come to so far is this:
  • Maintain each file in pastebin (obviously).
  • Additionally, maintain one more "master" pastebin file which contains the mapping filename -> pastebin address for all up-to-date files.
  • To update, a user would have to input the address of the master file. This would get sent through the system.
  • Every node downloads the master file, and then reads it to find out the addresses of all the other actual files.
However this does seem quite a bit of work to maintain, especially for incremental updates while building the system (remembering to copy all the links into the master file, the user having to type in the master file link every time to update). Another possibility I've been thinking of is storing the files on a separate server, where I can ensure that the address doesn't change. But then I lose the convenience of being able to download a file with a single program. Admittedly, writing a wget program is trivial. However this might be less than ideal if I ever plan to publicly distribute the system, as I can't guarantee continuous uptime of my web space forever.

I would like to know if there is some kind of a "standard" way to deal with this issue. If your software consists of multiple programs, or is spread across multiple devices, how do you keep them all up to date? I have looked through the first few pages of all the forums, but I haven't found a good answer yet.
ChunLing #2
Posted 07 December 2012 - 10:16 PM
There isn't a single, standard answer. But you can send lua program files as rednet messages, and you can send urls the same way. So you can have a file on your various computers that contains the url's for the most recent pastebins of their program suite, and update that using a rednet message, or you can transmit the whole program files over rednet.
Abdiel #3
Posted 07 December 2012 - 10:48 PM
The problem with that is that the URLs will change. Therefore a user will have to maintain an up-to-date set of URLs. (Which is basically the solution I already wrote). I'm wondering whether it's possible for a program to somehow "discover" the new URLs by itself. Or potentially a completely different solution.
Lyqyd #4
Posted 08 December 2012 - 04:26 AM
Pastebin accounts are free and allow you to edit the contents of your paste without a new ID being created. You cannot do this through ComputerCraft, as there is no edit functionality in pastebin's API, but it is available through the website.
Abdiel #5
Posted 08 December 2012 - 09:18 AM
Pastebin accounts are free and allow you to edit the contents of your paste without a new ID being created. You cannot do this through ComputerCraft, as there is no edit functionality in pastebin's API, but it is available through the website.

/facepalm

I already have an account. I have noticed the Edit button, I just assumed it would do the same as the "Create a new version" button (which makes a new link).

Thanks, this solves the problem completely.
zekesonxx #6
Posted 09 December 2012 - 07:06 AM
Or you could, you know, NOT use pastebin.