services:nodeserv
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
services:nodeserv [2024/08/09 12:14] – jas | services: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. | ||
- | |||
- | 1. Create a directory in your home directory called " | ||
- | |||
- | Create the directory like this: | ||
- | |||
- | % mkdir ~/nodejs | ||
- | |||
- | 2. Create a subdirectory inside the " | ||
- | |||
- | For example, if you will be hosting two applications that you wish to name " | ||
- | |||
- | % mkdir ~/ | ||
- | |||
- | 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 " | ||
- | |||
- | The nodeserve command has 3 options: | ||
- | |||
- | < | ||
- | nodeserve add < | ||
- | nodeserve del < | ||
- | nodeserver list to list applications | ||
- | </ | ||
- | |||
- | For example, to let the server know you want " | ||
- | |||
- | < | ||
- | % nodeserve add app1 | ||
- | App ' | ||
- | </ | ||
- | |||
- | You can list that apps that you've made available: | ||
- | |||
- | < | ||
- | % nodeserve list | ||
- | |||
- | List of apps for user ' | ||
- | app1 -> Port 4000 | ||
- | </ | ||
- | |||
- | You can delete an app: | ||
- | |||
- | < | ||
- | % nodeserve del app1 | ||
- | App ' | ||
- | </ | ||
- | |||
- | NOTE: Deleting an app simply tells the Node web server that you don't want it to make the app available. | ||
- | | ||
- | Each user can add up to 10 applications. | ||
- | |||
- | 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: | ||
- | |||
- | < | ||
- | const port = process.env.PORT; | ||
- | server.listen(port, | ||
- | console.log(`Server is listening on port ${port}`); | ||
- | }); | ||
- | </ | ||
- | |||
- | 7. Simply access your app. For example, visit: https:// | ||
- | |||
- | 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. | ||
- | |||
- | 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. | ||
- | |||
- | * 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:// | ||
- | |||
- | * 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.1723220071.txt.gz · Last modified: 2024/08/09 12:14 by jas