Change node.js server port?

3,326 views
Skip to first unread message

Jeremy Canady

unread,
Jan 7, 2014, 5:53:55 PM1/7/14
to tiddl...@googlegroups.com
Is it possible to change the port the node.js server uses? 8080 is very common. It would be extremely handy to change the port with a simple command line switch. 

RA

unread,
Jan 7, 2014, 9:29:54 PM1/7/14
to tiddl...@googlegroups.com
On Linux:
Edit "node_modules/tiddlywiki/serve.sh", replacing literal "8080" with "$1", then start with "serve.sh <your_port>"

I'm sure you can adapt the above for Windows.

Jeremy Canady

unread,
Jan 8, 2014, 8:04:12 AM1/8/14
to tiddl...@googlegroups.com
Thanks RA.

I am using the node module and the tiddlywiki --server switch to start the server. After digging through the source code, I found I can actually just place the port after the --server switch.

tiddlywiki --server <port>

Michele Zaffalon

unread,
May 29, 2014, 9:40:59 AM5/29/14
to tiddl...@googlegroups.com
Jeremy,

Thanks for the pointer, that is interesting.

Could you point me to where in the code <port> is passed to node? From my question, you have guessed right, I am not familiar with Javascript...

Thank you,
michele

Matabele

unread,
May 29, 2014, 3:12:14 PM5/29/14
to tiddl...@googlegroups.com
Hi

There's a handy cross platform utility called 'zenity' for creating dialog boxes in shell scripts: https://en.wikipedia.org/wiki/Zenity

I use the following script (in Linux) to load my various wikis -- this allows me to choose both a wiki to serve and a port for the server:

#!/bin/sh
wiki
=$(zenity --title="Start Wikis" --list --height=300 --text="Choose which wiki to start" --radiolist --column="" --column="Wiki" a wiki1 b wiki2 c wiki3 ... x blank)
port
=$(zenity --title="Select Port" --list --height=300 --text="Choose which port" --radiolist --column="" --column="Port" a 8080 b 8081 c 8082 d 8083 ...)
cd
/path/to/wikis/$wiki; tiddlywiki --server $port || exit 1

-- where each of the parameters wiki1, wiki2 etc is the name of the folder containing the wiki.

regards

Michele Zaffalon

unread,
May 29, 2014, 11:39:18 PM5/29/14
to tiddl...@googlegroups.com
Hi,

Thank you for the reply but evidently I posed the question in a terrible way: I meant to ask how in the code the parameter <port> is passed to node.js.

I start the three tiddlywikis I use from the command line.

Best,
michele


--
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.

Jeremy Ruston

unread,
May 30, 2014, 3:59:43 AM5/30/14
to TiddlyWiki
Hi Michele

I meant to ask how in the code the parameter <port> is passed to node.js.

The port parameter is handled in server.js, which contains the HTTP server functionality:


As you can see, the port number is passed to TW on the command line as the final parameter to the --server command.

Best wishes

Jeremy


--
Jeremy Ruston
mailto:jeremy...@gmail.com

Michele Zaffalon

unread,
May 30, 2014, 4:58:42 PM5/30/14
to tiddlywiki
Thank you Jeremy, for your detailed answer.

Best regards,
michele
Reply all
Reply to author
Forward
0 new messages