Server: on-demand refresh of tiddler from filesystem

Hi everyone!

While working on a complex filter in javascript, on a server edition (but not BOB), I see that I have to stop and restart the server for each new version of my filter operator tiddler. This is really poor.

Sometimes ago, there was a topic about automatic reloading of updated files for a node.js server. It was told that it would be quite too much resources hungry and would definitely slow down the server.

But what about adding a functionality of requesting a file reload for any given set of filter (or even only one at a time)? It would be quite enough for my developing need. The functionality could be hosted on the “tools” part of the tiddler’s “information” menu. As well as being callable as a macro of course.

And how can/would you do such a reload?

1 Like

I have tried tiddlywiki-plugins/plugins/linonetwo/watch-fs at master · tiddly-gittly/tiddlywiki-plugins · GitHub but the chokidar watcer is really CPU consuming… And it is really hard for a plugin to get tw internal file index (title to file path and vise versa).

It barely worked, but use some CPU and will cause some bug when file is rapidly changed. So I finally abandon it.

Thank you @linonetwo for this plugin reference.

In the doc of it is written:

** How to sync changes to the browser? **

we can’t trigger sync from the server, so we have to set a smaller sync interval in the client side.

So this plugin ship with a large [[$:/config/SyncPollingInterval]] to disable the build-in sync,
and we add a new route /linonetwo/watch-fs-can-sync to the simple server, it will return true or false,
and browser will poll this route, to see if it needs to trigger a $tw.syncer.syncFromServer().


This seems to indicate that there is no way to manually trigger a resync simply becaue of a lack of an API for this. I would have a close look at the plugin code to see better about that.

@jypre is this because you are manipulating tiddlers outside the server, using a batch or automated process? Hence the need to trigger the server ?

Perhaps I am out of my depth here, but thinking outside the box you are in.

Why not look at getting a process that adds such a tiddler through a server connection (a browser session to add the tiddler), or the equivalent of writing a tiddler to the server.

Similarly if the server reload is not too impactful just trigger a server reload as needed or at a scheduled time to pick up the changes? As long as they are new tiddlers, and you can manipulate the titles to do so, there should be no conflicts.

Browser connections are quite good at reconnecting.

@TW_Tones No, I am just editing my javascript filter op source code with vim and would like to be able to sync my node server with it. Sometimes, it would be several such source code at the same times.

My machine is a modest one (celeron N4100 with 8Gb RAM, for only 6W of TDP and fanless) so I need to avoid any fancy features that hog CPU. Clicking on a button of one dedicated tiddler to echieve that synchronization would be OK for me.

2 Likes

use Best TW Dev Framework! Easy WYSIWYG plugin developing, support TypeScript

or watch-fs + GitHub - twcloud/tiddlyweb-sse