Help:Toolforge/Deno
Deno is not natively installed in Toolforge. However, it can still be used fairly well through user level installations. In this tutorial, we will use the Node.js image.
Installation
To install Deno, login to a the Toolforge bastion, become
your tool, and run:[1]
curl -fsSL https://deno.land/install.sh | sh
It is recommended to examine the script before executing it.
Add the following to your .profile
or .bashrc
, to put deno in the PATH variable:
export PATH=~/.deno/bin:$PATH
Setting up Deno application
As with the conventions for Toolforge node.js applications, place your app code in $HOME/www/js
directory. Running npm start
must launch the service. So, add a package.json file that includes:
"scripts": {
"start": "~/.deno/bin/deno run -A src/main.ts"
}
Note that we have to specify the full path to deno executable even though we added deno to PATH above. This is because your .profile
is not executed when Kubernetes starts the deployment.
In src/main.ts
, implement your app. A basic example to get you started:[2]
Deno.serve((_req) => {
return new Response("Hello, World!");
});
Run webservice node18 start
. By default, deno listens to connections on port 8000, the same port used in the Kubernetes image.
Navigate to <TOOLNAME>.toolforge.org. If all went well, you should see "Hello, World!" in your browser. If not, use kubectl logs deploy/<TOOLNAME>
to see what went wrong.
Libraries
- oak – HTTP server library for requirements not fulfilled by Deno standard library.
- mwn – MediaWiki API client for node.js that works fine on Deno as well.
Starting with version 2, Deno is compatible with npm packages written for Node.js.[3] You may find these useful as well:
- mysql2 – Database client library to interface with MariaDb replicas and ToolsDB.
- iovalkey – Client library to interface with Toolforge Redis.
- @elastic/elasticsearch – Client library to interface with Toolforge Elasticsearch and CirrusSearch OpenSearch replicas.
Communication and support
Support and administration of the WMCS resources is provided by the Wikimedia Foundation Cloud Services team and Wikimedia movement volunteers. Please reach out with questions and join the conversation:
- Chat in real time in the IRC channel #wikimedia-cloud connect or the bridged Telegram group
- Discuss via email after you have subscribed to the cloud@ mailing list
- Subscribe to the cloud-announce@ mailing list (all messages are also mirrored to the cloud@ list)
- Read the News wiki page
Use a subproject of the #Cloud-Services Phabricator project to track confirmed bug reports and feature requests about the Cloud Services infrastructure itself
Read the Cloud Services Blog (for the broader Wikimedia movement, see the Wikimedia Technical Blog)