wsl 子系统ubuntu 18.04安装shinobi以及shinobi开机自动启动命令

ubuntu手动安装shinobi:
apt install git -y
git clone https://gitlab.com/Shinobi-Systems/Shinobi.git Shinobi
cd Shinobi
chmod +x INSTALL/ubuntu.sh && INSTALL/ubuntu.sh
在安装过程种,需要操作:
1、lib库安装是否自动启动相关联的service 实际显示是否需要重启ssh服务,直接选NO
2、安装mysql
3、选择mysql root密码
4、安装shinobi mysql数据库
5、Start Shinobi and set to start on boot
安装完成后,systemctl指令存在,但在使用过程中出现下面的提示:
root@DESKTOP-I9D9QF6:~/Shinobi# systemctl status ssh
System has not been booted with systemd as init system (PID 1). Can't operate.
接着查询mysql的状态:
root@DESKTOP-I9D9QF6:~/Shinobi# service mysql status

  • /usr/bin/mysqladmin Ver 9.1 Distrib 10.1.47-MariaDB, for debian-linux-gnu on x86_64
    Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Server version 10.1.47-MariaDB-0ubuntu0.18.04.1
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /var/run/mysqld/mysqld.sock
Uptime: 9 min 29 sec

Threads: 1 Questions: 463 Slow queries: 0 Opens: 169 Flush tables: 1 Open tables: 31 Queries per second avg: 0.813
接着pm2 list下发现没有启动相关的shinobi,启动如下:
pm2 start camera.js
pm2 start cron.js
pm2 startup
pm2 save ----实际作用呢??需要查阅 在/root/.pm2中翻阅下
pm2 list
注意pm2 startup输出如下:

root@DESKTOP-I9D9QF6:~# pm2 startup
[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=root
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
Environment=PATH=/usr/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
Environment=PM2_HOME=/root/.pm2
PIDFile=/root/.pm2/pm2.pid

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-root.service
Command list
[ 'systemctl enable pm2-root' ]
[PM2] Writing init configuration in /etc/systemd/system/pm2-root.service
[PM2] Making script booting at startup...
[PM2] [-] Executing: systemctl enable pm2-root...
Configuration file /etc/systemd/system/pm2-root.service is marked world-writable. Please remove world writability permission bits. Proceeding anyway.
[PM2] [v] Command successfully executed.
+---------------------------------------+
[PM2] Freeze a process list on reboot via:
$ pm2 save

[PM2] Remove init script via:
$ pm2 unstartup systemd

pm2 save输出如下:

root@DESKTOP-I9D9QF6:~# pm2  save
[PM2] Saving current process list...
[PM2] Successfully saved in /root/.pm2/dump.pm2

pm2 list输出如下:

root@DESKTOP-I9D9QF6:~# pm2  list
┌──────────┬────┬──────┬─────┬────────┬─────────┬────────┬──────┬───────────┬──────┬──────────┐
│ App name │ id │ mode │ pid │ status │ restart │ uptime │ cpu  │ mem       │ user │ watching │
├──────────┼────┼──────┼─────┼────────┼─────────┼────────┼──────┼───────────┼──────┼──────────┤
│ camera   │ 0  │ fork │ 97  │ online │ 0       │ 6m     │ 0.3% │ 77.4 MB   │ root │ disabled │
│ cron     │ 1  │ fork │ 157 │ online │ 0       │ 6m     │ 0%   │ 30.7 MB   │ root │ disabled │
└──────────┴────┴──────┴─────┴────────┴─────────┴────────┴──────┴───────────┴──────┴──────────┘
 Use `pm2 show <id|name>` to get more details about an app

启动过程中windows提示需要node通过防火墙,选允许。
接着测试下:WSL子系统在重启的情况下相关的服务是否可以正常启动,非常重要的是mysql服务,通过wslconfig /t ubuntu-18.04来模拟
关闭wsl子系统(因为reboot命令在wsl子系统中是不能使用的)结论:
mysql服务没有启动;pm2 list发现2个camera.js和cron.js没有启动,手动启动的时候注意camera.js和cron.js的路径在shinobi目录下

shinobi开机自启动:
service ssh start
service mysql start
sudo pm2 start camera.js
sudo pm2 start cron.js
sudo pm2 startup
sudo pm2 save
sudo pm2 list

参考:
How to Install Ubuntu 18.04 Server on Windows 10 https://hub.shinobi.video/articles/view/7G3dpxexzB3Lw5t

原文地址:https://www.cnblogs.com/weihua2020/p/13927489.html