Skip to content

Getting started

Ardalan Samimi edited this page Jun 30, 2018 · 2 revisions

Getting started

Before installing Raspbot, please ensure that the following prerequisites are met:

Required:

  • Node Package Manager (recommended version 5.7.1+)
  • NodeJS (recommended version 10.4.1+)
  • Python (developed for version 2.7.10)
  • psutil library (developed using version 5.4.3)

Optional:

  • PM2 (only required to use the Bootstrapper app)

Installing Raspbot

Clone this repository on your Raspberry Pi:

$ git clone https://github.com/pkrll/Raspy

And run make install in the project root folder to install and set up the server:

$ cd Raspy
$ make install

Manually building the client (optional)

The folder dist inside ./raspbot already contains the latest build of the client. Running the server will use the files there. You can also manually build the client app, by typing make build in the root folder. This might take a while, so grab a snack and wait for the installation and build processes to finish.

Running the server

After installing all dependencies and setting up the server, you can run the server with make server in the root folder.

It is, though, recommended to use a process manager to run the server.

With a process manager

To daemonize the application, you can use PM2, which is a process manager for NodeJS applications. If you do not have PM2 already, install it:

$ sudo npm install -g pm2

Run the server with PM2

Use make start to run the server in the background. The NODE_ENV will automatically be set to "production" when using the start rule.

$ make start

[PM2] Applying action restartProcessId on app [server](ids: 0)
[PM2] [server](0) βœ“
[PM2] Process successfully started
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ App name β”‚ id β”‚ mode β”‚ pid   β”‚ status β”‚ restart β”‚ uptime β”‚ cpu β”‚ mem       β”‚ user  β”‚ watching β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Raspbot    β”‚ 0  β”‚ fork β”‚ 13141 β”‚ online β”‚ 0       β”‚ 0s     β”‚ 66% β”‚ 13.9 MB   β”‚ pkrll β”‚ disabled β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
 Use `pm2 show <id|name>` to get more details about an app

Stop the server with PM2

Use make stop to stop the server.

Autostart server on boot

Follow these steps to make PM2 run on startup.

  1. Start the application with make start (if not already running).
  2. Save the current process list with pm2 save.
  3. Run pm2 startup systemd and copy and paste the command produced by the script.

Example

$ make start

$ pm2 save
[PM2] Saving current process list...
[PM2] Successfully saved in /home/pkrll/.pm2/dump.pm2

$ pm2 startup systemd
[PM2] Init System found: systemd
[PM2] To setup the Startup Script, copy/paste the following command:
sudo env PATH=$PATH:[...] startup systemd -u USER --hp /home/USER

$ sudo env PATH=$PATH:[...] startup systemd -u USER --hp /home/USER

For more information on how to use PM2, check out the official documentation or this quickstart guide.