-
Notifications
You must be signed in to change notification settings - Fork 2
Appendix
We need to download MobaXterm installer from here https://mobaxterm.mobatek.net/download.html. We will choose Home edition
.png?raw=true)
and we will use installer edition.
.png?raw=true)
Let unzip and install MobaXterm.
.png?raw=true)
We just follow installation steps.

Once it is installed, let open MobaXterm and click new session
Then click SSH
and enter the following information to get ssh connection to AI bot
SSH will ask you to enter password. The password for Nanopi is "pi" and for Raspberry Pi is "raspberry". Note that when you type the password, it will not show but it is actually there. After the password is entered, we can just press Enter key.
Once you get in, you will see the following pages.
.png?raw=true)
We can create, edit and delete file from the MobaXterm interface.

On the left of MobaXterm, you can see file and folder listing and on the right, you can see the command terminal.
We can select any file on left panel to edit. For example, if we want to edit test.py, we just right click on file name and choose open with default editor
Then the editor will show up and we can edit the file.
.png?raw=true)
We can create a new file in current directory by clicking New file.
We then enter a file name and click OK.
Our newly created file will show up on the file panel.
.png?raw=true)
We can use pm2 to start our project when robot start.
pm2 start /home/pi/kbclientNew/nectec-client/dist/fa/test1.py --name test1 --interpreter python3
/home/pi/kbclientNew/nectec-client/dist/fa/test1.py where fa is the project name
pi@KidBrightAI02:~$ pm2 start /home/pi/kbclientNew/nectec-client/dist/fa/test1.py --name test1 --interpreter python3
[PM2] Starting /home/pi/kbclientNew/nectec-client/dist/fa/test1.py in fork_mode (1 instance)
[PM2] Done.
┌─────┬──────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu │ mem │ user │ watching │
├─────┼──────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 1 │ app3 │ default │ 1.0.0 │ fork │ 1071 │ 29m │ 0 │ online │ 0% │ 367.3mb │ pi │ disabled │
│ 0 │ index │ default │ 1.0.0 │ fork │ 1064 │ 29m │ 0 │ online │ 0% │ 60.5mb │ pi │ disabled │
│ 2 │ test1 │ default │ 0.1.0 │ fork │ 3460 │ 0s │ 0 │ online │ 100% │ 7.8mb │ pi │ disabled │
└─────┴──────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
[PM2][WARN] Current process list running is not in sync with saved list. Type 'pm2 save' to synchronize or enable autosync via 'pm2 set pm2:autodump true'
Then we need to save all running sessions.
pi@KidBrightAI02:~$ pm2 save
[PM2] Saving current process list...
[PM2] Successfully saved in /home/pi/.pm2/dump.pm2
Next, we let the pm2 start all sessions when the system start up
pi@KidBrightAI02:~$ pm2 startup
[PM2] Init System found: systemd
pi
[PM2] To setup the Startup Script, copy/paste the following command:
sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u pi --hp /home/pi
We need to copy and paste the last line like so
pi@KidBrightAI02:~$ sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u pi --hp /home/pi
pm2 list to show all running sessions.
pi@KidBrightAI02:~$ pm2 list
┌─────┬──────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu │ mem │ user │ watching │
├─────┼──────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 1 │ app3 │ default │ 1.0.0 │ fork │ 1080 │ 76s │ 0 │ online │ 0% │ 370.1mb │ pi │ disabled │
│ 0 │ index │ default │ 1.0.0 │ fork │ 1073 │ 76s │ 0 │ online │ 0.4% │ 70.7mb │ pi │ disabled │
│ 2 │ test1 │ default │ 0.1.0 │ fork │ 1085 │ 76s │ 0 │ online │ 38.5% │ 28.3mb │ pi │ disabled │
└─────┴──────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
We can stop test1 by using pm2 stop test1.
pi@KidBrightAI02:~$ pm2 stop test1
[PM2] Applying action stopProcessId on app [test1](ids: 2)
[PM2] [test1](2) ✓
┌─────┬──────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu │ mem │ user │ watching │
├─────┼──────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 1 │ app3 │ default │ 1.0.0 │ fork │ 1080 │ 86s │ 0 │ online │ 0% │ 370.1mb │ pi │ disabled │
│ 0 │ index │ default │ 1.0.0 │ fork │ 1073 │ 86s │ 0 │ online │ 0% │ 58.2mb │ pi │ disabled │
│ 2 │ test1 │ default │ 0.1.0 │ fork │ 0 │ 0 │ 0 │ stopped │ 0% │ 0b │ pi │ disabled │
└─────┴──────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
Once test1 is stopped. We can save all remaining sessions.
pi@KidBrightAI02:~$ pm2 save
[PM2] Saving current process list...
[PM2] Successfully saved in /home/pi/.pm2/dump.pm2
We can then pm2 startup again
pi@KidBrightAI02:~$ pm2 startup
[PM2] Init System found: systemd
pi
[PM2] To setup the Startup Script, copy/paste the following command:
sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u pi --hp /home/pi
and copy the last line.
sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u pi --hp /home/pi
pi@KidBrightAI02:~$ sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u pi --hp /home/pi
[PM2] Init System found: systemd
Platform systemd
Template
[Unit]
Description=PM2 process manager
Documentation=https://pm2.keymetrics.io/
After=network.target
[Service]
Type=forking
User=pi
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
Environment=PATH=/opt/ros/melodic/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
Environment=PM2_HOME=/home/pi/.pm2
PIDFile=/home/pi/.pm2/pm2.pid
Restart=on-failure
ExecStart=/usr/lib/node_modules/pm2/bin/pm2 resurrect
ExecReload=/usr/lib/node_modules/pm2/bin/pm2 reload all
ExecStop=/usr/lib/node_modules/pm2/bin/pm2 kill
[Install]
WantedBy=multi-user.target
Target path
/etc/systemd/system/pm2-pi.service
Command list
[ 'systemctl enable pm2-pi' ]
[PM2] Writing init configuration in /etc/systemd/system/pm2-pi.service
[PM2] Making script booting at startup...
[PM2] [-] Executing: systemctl enable pm2-pi...
[PM2] [v] Command successfully executed.
+---------------------------------------+
[PM2] Freeze a process list on reboot via:
$ pm2 save
[PM2] Remove init script via:
$ pm2 unstartup systemd
pi@KidBrightAI02:~$