השרת שניתן להריץ עליו node.js הוא delta-tomcat-vm .
יש לבחור מספר פורט - נא השתמש במספר בין 40000 ו-40999
על מנת לגלות אילו פורטים כבר בשימוש, הריצו 'netstat -an | grep ':[4]0. אם תתקלו בבעיות מאוחר יותר, תבדקו שוב; יתכן שמישהו השתמש בפורט אבל לא הריץ את השרת שלו כשבדקתם.
שימו לב, העבודה מתבצעת בספריה בשם ה-username שלכם ב- specific/scratch/ אשר אינו מגובה, כך שכדאי שתמיד תשמרו עותק של קבצי המקור שלכם ב-home directory שלכם.
כדי ליצור ספריית משלכם, הריצו:
ssh delta-tomcat-vm
sudo create-my-django-dir
mkdir /specific/scratch/<username>/django/myapp
cd /specific/scratch/<username>/django/myapp
Node.js already installed at our system we have different versions - the latest installed at:
setenv PATH /usr/local/lib/node-v10.15.0/bin:$PATH
setenv HOME /specific/scratch/<username>/django
Initializes your project
npm init
This creates a package.json file in your myapp folder
Install Express in the myapp directory (you can install what ever you like - we have some modules already install at /usr/local/lib/node-v10.15.0/lib/node_modules that can be used)
npm install express --save
Start your text editor of choice and create a file named app.js.
Write the following:
var express = require('express'); var app = express();
app.get('/', function (req, res) { res.send('Hello World!'); });
app.listen(40111, function () { console.log('Example app listening on port 40111!'); });
Start your application node app.js
כשהוא פועל, אתם יכולים להתחבר בעזרת דפדפן אינטרנט אל הכתובת 'http://server:port',
(למשל, 'http://delta-tomcat-vm.cs.tau.ac.il:40111').
If you need to copy you application from your HOME_DIR to delta-tomcat-vm:
Use scp -r to copy your application files from ~home to delta-tomcat-vm - You do NOT have access to your ~home data from delta-tomcat-vm !!!!
nova 1% scp -r ~<your django application data> delta-tomcat-vm:/specific/scratch/<username>/django/