This project is a bootstrapper for downloading, setting up, and running a Node.js application. It automates the process of fetching the latest version of an app from a remote URL, unzipping it, installing dependencies, and starting the app.
- Automatically downloads the latest version of the app.
- Cleans up old versions before setup.
- Installs dependencies and starts the app.
- Compares the current app version with the latest version to decide whether to update.
- Node.js and npm installed on your system.
- Ensure you have access to the URLs specified in the
.envfile.
-
Clone this repository:
git clone <repository-url> cd shell
-
Install dependencies:
npm install
-
Configure the
.envfile (see below for details). -
Start the bootstrapper:
npm start
The .env file contains environment variables required for the app to function. Below is an explanation of each variable:
APP_URL: The URL to download the zipped Node.js app.INFO_URL: The URL to fetch the latest version information of the app.
API_URL=https://app.begrabby.com
SHELL_ID=abc-123-def-456
SENSOR_CODE=123 # password for the shell- Install PM2:
npm install pm2@latest -g
- Run the app with the name
pm2 start app.js --name MY_APP_NAME
- Set the startup process: https://pm2.keymetrics.io/docs/usage/startup/
pm2 startup
# Then copy/paste the displayed command onto the terminal
pm2 save
The info-template.json file is used to define the structure of the version information fetched from the INFO_URL. Below is an example:
{
"version": "2.0"
}This file ensures that the app can compare the current version with the latest version available remotely.
- If the app fails to start, ensure the
.envfile is correctly configured. - Check your internet connection if the app cannot download the zip file.
- Ensure Node.js and npm are installed and accessible in your system's PATH.
This project is licensed under the ISC License.