[TW5] Node.js Install: Launching 'tiddlywiki --server' on startup.

3,545 views
Skip to first unread message

Wildscot

unread,
Jan 12, 2014, 6:47:22 PM1/12/14
to tiddl...@googlegroups.com
I've installed TW5 with node.js on a VPS running Ubuntu Server 12.04. 

I'm looking for the best way to have the 'tiddlywiki --server' launch when I boot the server, rather than manually.
I'm new to node.js and from having a quick look it seems I want to be looking at 'forever' and an upstart script, does that sound about right?

Before I start delving into it I thought I'd check with the community whether I was barking up the right tree or whether there was another recommended approach.

Many Thanks,

James

Jeremy Ruston

unread,
Jan 13, 2014, 8:14:59 AM1/13/14
to TiddlyWiki
Hi James

There's just been a similar question on GitHub:


I don't personally have experience of these configurations, but would welcome feedback so that I can add the necessary details to the documentation.

Best wishes

Jeremy




--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/groups/opt_out.



--
Jeremy Ruston
mailto:jeremy...@gmail.com
Message has been deleted

Wildscot

unread,
Jan 15, 2014, 12:58:37 PM1/15/14
to tiddl...@googlegroups.com, jeremy...@gmail.com
OK, after pulling my hair out for a couple of days I seem to have it working.
I'll make it clear though this is all about cut & paste and stubbornness rather than any real understanding, YMMV.

This is Tiddlywiki 5, Node.js install on a VPS running Ubuntu 12.04LTS, launching at boot. 
The same principal should apply to any distribution using Upstart though.

I installed node.js following this guide. You can ignore the penultimate step as mentioned in the comments as the Node Package Manager seems to be bundled now.

Install Tiddlywiki on Node.js as outlined in the docs.

Add an Upstart script to /etc/init

$sudo nano /etc/init/tiddywiki-forever.conf

# /etc/init/tiddlywiki-forever.conf
 
description 
"Tiddlywiki 5 Launcher"
author      
"J Donaldson"


# If network interface is wireless
# start on (local-filesystems and net-device-up IFACE=wlan0)
# If network interface is Ethernet
start on (local-filesystems and net-device-up IFACE=eth0)
 
stop on shutdown
 
# Automatically Respawn:
respawn
respawn limit 
99 5


# We run as this user instead of as root (the default user).
# Depending on your environment you may want to add a user for node.
setuid user
 
script
    
# Not sure why $HOME is needed, but it seems to be:
    
export HOME="/home/user/mywiki"
    
    cd $HOME
 
    
exec /home/user/local/bin/node /home/user/local/lib/node_modules/tiddlywiki/tiddlywiki.js --server

end script

You will need to tweak this to match your details and adding logging may be a good idea.

$sudo start tiddlwiki-forever
will launch it

$sudo stop tiddlwiki-forever
will stop it and it should run as soon as your network comes up after a reboot.

You ought to be able to add any of the server commands too.
I'm not wise enough to know if this is the best way to achieve this or whether it is secure, robust or whatever else so use it at your own risk.

Wildscot

unread,
Jan 15, 2014, 1:15:59 PM1/15/14
to tiddl...@googlegroups.com, jeremy...@gmail.com
Remember, depending on your environment you may need to change the interface above. 
I was testing on a local virtual machine with 'eth0' as the network interface but the actual VPS doesnt.

$ ifconfig

will list your interfaces and edit accordingly.

Marcel Kaczala

unread,
Jan 17, 2014, 9:46:00 AM1/17/14
to tiddl...@googlegroups.com, jeremy...@gmail.com
And how to ser the name_server for DNS configuration? 

Marcel Kaczala

unread,
Jan 20, 2014, 7:33:14 AM1/20/14
to tiddl...@googlegroups.com, jeremy...@gmail.com

Em quarta-feira, 15 de janeiro de 2014 15h58min37s UTC-2, Wildscot escreveu:

Chris Lott

unread,
Jan 20, 2014, 3:13:25 PM1/20/14
to tiddl...@googlegroups.com
The simple command:
forever start --spinSleepTime 10000 /usr/local/lib/node_modules/tiddlywiki/tiddlywiki.js --server

works for me except that I can't figure out how to specify the directory where that wiki lives on this command line. I assume this is why $HOME is being redefined, but that has other consequences doesn't it (since $HOME is used in all kinds of places to specify the user's home directory, aka ~)?

Marcel Kaczala

unread,
Jan 20, 2014, 6:26:47 PM1/20/14
to tiddl...@googlegroups.com
No, you have to forever start the bin:

forever start --spinSleepTime 10000 ~/local/bin/tiddlywiki --server

dcort...@gmail.com

unread,
Jan 25, 2014, 6:28:15 AM1/25/14
to tiddl...@googlegroups.com
Hi all,
Also found some useful hints from the install of ghost (which is also based on node.js), for users of linux for example


http://docs.ghost.org/installation/deploy/

    apt-get install supervisor
    vi /etc/supervisor/conf.d/tiddlywiki.conf


```
[program:tiddlywiki]
command = node /usr/local/bin/tiddlywiki --verbose --server 8080  $:/core/save/all text/plain text/html mylogin mypassword
directory = /home/whatever-you-want/wiki/tw5
user = myself
autostart = true
autorestart = true
stdout_logfile = /var/log/supervisor/tw5.log
stderr_logfile = /var/log/supervisor/tw5_err.log
environment = NODE_ENV="production"
```

     supervisorctl start

Wildscot

unread,
Dec 15, 2014, 5:56:58 PM12/15/14
to tiddl...@googlegroups.com
Supervisor may well be the way to go, I'll have a look into it. 

Meanwhile...

I've just updated Tiddlywiki to 5.1.5 from one of the betas - it broke and I couldn't get at it from the browser at all.
After much fiddling about I've realised that it's now serving from 127.0.0.1 in order to get it working I had to edit that Upstart script, I'm assuming it would be the same for the supervisor script.

--server 8080  $:/core/save/all text/plain text/html mylogin mypassword 0.0.0.0

I'm guessing it used to serve on 0.0.0.0 by default?

Wildscot

unread,
Dec 15, 2014, 6:07:54 PM12/15/14
to tiddl...@googlegroups.com
Actually I see now that this was covered in a few other threads, probably worth mentioning in regard to these scripts anyway.

Jeremy Ruston

unread,
Dec 16, 2014, 8:36:36 AM12/16/14
to TiddlyWiki
Hi James

Glad you've got things working.

>  Not sure why $HOME is needed, but it seems to be:

The reason is that you've omitted the wiki folder from the tiddlywiki command line, causing it to default to the current folder. You could rephrase the command as:

exec /home/james/local/bin/node /home/james/local/lib/node_modules/tiddlywiki/tiddlywiki.js /home/user/mywiki --server

Best wishes

Jeremy.

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.

anony_geek

unread,
Mar 31, 2016, 8:46:55 AM3/31/16
to TiddlyWiki
You can do it from cron. You need to specify the paths of everything to make sure it picks it up. 

For example, first run "crontab -e" to open the crontab and add this line at the end. Alter the parts in <>'s to your own

This is the basic one:
@reboot <path to tiddly>/tiddlywiki <full path to wiki> --server 

To get the <path to tiddly> run "whereis tiddlywiki".
An example fully filled out one would be:

@reboot /usr/local/bin/tiddlywiki /home/user/tiddly/mywiki --server


You can add your extra server options as well to add user names and remote access like so:
@reboot /usr/local/bin/tiddlywiki /home/user/tiddly/mywiki --server 8080 "" "" "" "<username>" "<password>"  0.0.0.0 ""
Reply all
Reply to author
Forward
0 new messages