Friday, September 25, 2015

running tiddlywiki on windows as a service

Referenced below two links: http://tiddlywiki.com/static/Installing%2520TiddlyWiki%2520on%2520Node.js.html
http://www.rubix.nl/blogs/running-tiddlywiki-service-linux-and-windows

But they are not detai enough for me, so list down my steps after spending half an hour on the setup.

1. download node.js from https://nodejs.org/dist/latest/ and installed it.

2. now I have npm.exe to install tiddlywiki.


C:\Users\liqy>npm install -g tiddlywiki
C:\Users\liqy\AppData\Roaming\npm\tiddlywiki -> C:\Users\liqy\AppData\Roaming\npm\node_modules\tiddlywiki\tiddlywiki.js
tiddlywiki@5.1.9 C:\Users\liqy\AppData\Roaming\npm\node_modules\tiddlywiki

Note that tiddlywiki.js is installed under AppData sub-directory by default.

C:\Users\liqy>

3. now initialize the notebook named "mywiki". The step should be followed, which same as on Linux platform.


Note that the directory for notebook "mywiki" should be empty.

C:\Users\liqy\AppData\Roaming\npm\node_modules\tiddlywiki>node .\tiddlywiki.js "
D:\mydoc\pp\sync\mywiki" --init server
Error: Wiki folder is not empty

--this is due to I put a local copy of tiddlywik html file there.

--after remove it , and try again

C:\Users\liqy\AppData\Roaming\npm\node_modules\tiddlywiki>node .\tiddlywiki.js "
D:\mydoc\pp\sync\mywiki" --init server
Copied edition 'server' to D:\mydoc\pp\sync\mywiki


3.2 If not, I hit below error when I try to start the service

C:\Users\liqy\AppData\Roaming\npm\node_modules\tiddlywiki>node .\tiddlywiki.js "
D:\mydoc\pp\sync\mywiki" --server 88 --verbose --rendertiddler $:/core/save/all
mywiki.html text/plain
Warning: Wiki folder 'D:\mydoc\pp\sync\mywiki' does not exist or is missing a ti
ddlywiki.info file
Serving on 127.0.0.1:88
(press ctrl-C to exit)

$:/core/modules/commands/server.js:304
        if($tw.boot.wikiInfo.plugins.indexOf("tiddlywiki/tiddlyweb") === -1 || $
tw.boot.wikiInfo.plugins.indexOf("tiddlywiki/filesystem") === -1) {
                            ^
TypeError: Cannot read property 'plugins' of null
    at Command.execute ($:/core/modules/commands/server.js:304:22)
    at Commander.executeNextCommand ($:/core/modules/commander.js:82:14)
    at Commander.execute ($:/core/modules/commander.js:46:7)
    at Object.exports.startup ($:/core/modules/startup/commands.js:34:12)
    at $tw.boot.executeNextStartupTask (C:\Users\liqy\AppData\Roaming\npm\node_m
odules\tiddlywiki\boot\boot.js:1905:10)
    at $tw.boot.executeNextStartupTask (C:\Users\liqy\AppData\Roaming\npm\node_m
odules\tiddlywiki\boot\boot.js:1903:21)
    at $tw.boot.executeNextStartupTask (C:\Users\liqy\AppData\Roaming\npm\node_m
odules\tiddlywiki\boot\boot.js:1903:21)
    at $tw.boot.executeNextStartupTask (C:\Users\liqy\AppData\Roaming\npm\node_m
odules\tiddlywiki\boot\boot.js:1903:21)
    at $tw.boot.executeNextStartupTask (C:\Users\liqy\AppData\Roaming\npm\node_m
odules\tiddlywiki\boot\boot.js:1903:21)
    at $tw.boot.startup (C:\Users\liqy\AppData\Roaming\npm\node_modules\tiddlywi
ki\boot\boot.js:1856:11)








4.  Try to start the service to see if any error, before adding as a service

The command
node .\tiddlywiki.js "D:\mydoc\pp\sync\mywiki" --server 88 --verbose --rendertiddler $:/core/save/all mywiki.html text/plain

This is to start the tiddly service listening on localhost port 88 , for notebook named "mywiki"

C:\Users\liqy\AppData\Roaming\npm\node_modules\tiddlywiki>node .\tiddlywiki.js "
D:\mydoc\pp\sync\mywiki" --server 88 --verbose --rendertiddler $:/core/save/all
mywiki.html text/plain
Serving on 127.0.0.1:88
(press ctrl-C to exit)
Boot log:
  Startup task: load-modules
  Startup task: info after: load-modules before: startup
  Startup task: startup after: load-modules
  Startup task: story after: startup
  Startup task: commands platforms: node after: story
Executing command: rendertiddler $:/core/save/all mywiki.html text/plain
syncer-server: Dispatching 'save' task: $:/StoryList
FileSystem: Saved file D:\mydoc\pp\sync\mywiki\tiddlers\$__StoryList.tid
syncer-server: Dispatching 'save' task: $:/StoryList
FileSystem: Saved file D:\mydoc\pp\sync\mywiki\tiddlers\$__StoryList.tid


5. Confirmed no issue with method, pressed CTRL+C to stop it , and invoke the nssm installed to add service to the windows registry.

D:\tools\nssm\win32>nssm install tiddlywiki
Service "tiddlywiki" installed successfully!

The startup directory in my case is:

 C:\Users\liqy\AppData\Roaming\npm\node_modules\tiddlywiki

The arguments in my case is :

.\tiddlywiki.js "D:\mydoc\pp\sync\mywiki" --server 88 --verbose --rendertiddler $:/core/save/all mywiki.html text/plain

By the way, command to edit the tiddlywiki is
D:\tools\nssm\win32>nssm edit  tiddlywiki



6.Verify that "tiddlywiki" service is added in "control panel/services"



7. Finally I see it in my web browser with address "http://localhost:88"




8. If there is existing tiddlers in a single html file, I believe tiddlywiki upload command can help to migrate existing tiddlers.







No comments:

Post a Comment