User Tools

Site Tools


services:nodeserv

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
services:nodeserv [2024/08/09 12:15] jasservices:nodeserv [2024/08/12 14:01] (current) – removed jas
Line 1: Line 1:
-====== Nodeserve User Documentation ====== 
- 
-Nodeserve allows you to make NodeJS applications available for others to access.  Follow these instructions for enabling access to your NodeJS application. 
- 
-1.  Create a directory in your home directory called "nodejs" This will be used for hosting your NodeJS applications. 
- 
-Create the directory like this: 
- 
-  % mkdir ~/nodejs 
- 
-2.  Create a subdirectory inside the "nodejs" directory for each application that you intend to host. 
- 
-For example, if you will be hosting two applications that you wish to name "app1" and "app2", you would create a directory for each application as follows: 
- 
-  % mkdir ~/nodejs/app1 ~/nodejs/app2 
- 
-3.  Develop your NodeJS app in its respective directory. 
- 
-4.  Inside each application directory, create a package.json file.  Use the  You //npm init -y// command to create the package.json file. 
- 
-5.  Let the server know that you want your app to be accessible using the "nodeserve" command. 
- 
-The nodeserve command has 3 options: 
- 
-<code> 
-nodeserve add <appname> to add an application 
-nodeserve del <appname> to delete an application 
-nodeserver list to list applications 
-</code> 
- 
-For example, to let the server know you want "app1" to be available: 
- 
-<code> 
-% nodeserve add app1 
-App 'app1' added for user 'jas' with port 4000. 
-</code> 
- 
-You can list that apps that you've made available: 
- 
-<code> 
-% nodeserve list 
- 
-List of apps for user 'jas': 
-  app1 -> Port 4000 
-</code> 
- 
-You can delete an app: 
- 
-<code> 
-% nodeserve del app1 
-App 'app1' deleted for user 'jas'. 
-</code> 
- 
-NOTE: Deleting an app simply tells the Node web server that you don't want it to make the app available.  It doesn't delete your app. 
-   
-Each user can add up to 10 applications.  If you need to make more apps available, you can always delete some and add others.   
- 
-6.  When writing your server code, please make sure that you do not hard-code the port number. Instead, your code should read the port number from the environment - our system will let your app know which port number to use. 
- 
-For example: 
- 
-<code> 
-const port = process.env.PORT; 
-server.listen(port, () => { 
-    console.log(`Server is listening on port ${port}`); 
-}); 
-</code> 
- 
-7.  Simply access your app.  For example, visit: https://nodeserve.eecs.yorku.ca/<user>/<app> 
- 
-The web server will look up the port number for your app, set the port number in the PORT environment variable, then start your app running as your user id on the Node web server.  It will automatically forward web traffic from https://nodeserve.eecs.yorku.ca/<user>/<app> to your app!  You can even use query strings like this: ttps://nodeserve.eecs.yorku.ca/<user>/<app>?opt1=option1&opt2=option2 
- 
-Other Notes: 
- 
-  * In order to ensure that the server is not overloaded with applications which are not running, your application will automatically shutdown after approximately 10 minutes of inactivity.  Note however that by calling the application again, it will start again. 
- 
-  * If before those 10 minutes have expired, you wish to terminate your application (because you've changed it, and you want the web server to re-load it), then simply visit this web page: [[https://nodeserve.eecs.yorku.ca/terminate]]   After logging in with your EECS user ID and password, ALL node apps running on the server running as you will be terminated.  
- 
-  * Finally, since you don't have access to the console for your server API, you'll want to make sure that the server has been tested, and is working prior to adding it to the server. 
  
services/nodeserv.1723220121.txt.gz · Last modified: 2024/08/09 12:15 by jas

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki