NodeRED常用操作

Posted by Dapenson on April 20, 2020

NodeRED常用操作

记录使用在云服务器操作NodeRED过程中常用的一些过程或方法

重启NodeRED

通过命令行重启

我的NodeRED在pm2的自启动管理下,因此使用pm2进行重启

pm2 restart all 
通过面板重启

另外一种方法就是通过控制面板直接重启

可导入以下节点之后点击即可重启

[{"id":"8497fd50.d66e1","type":"exec","z":"4487e413.bb781c","command":"sudo ","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"System Command","x":720,"y":370,"wires":[[],[],[]]},{"id":"c8687228.7cd88","type":"inject","z":"4487e413.bb781c","name":"Restart node-RED","topic":"","payload":"node-red-restart","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":480,"y":370,"wires":[["8497fd50.d66e1"]]}]

修改面板登录用户名密码

1 安装node-red-admin工具

npm install -g node-red-admin

2 使用工具生成密码

node-red-admin hash-pw

3 输入你要的密码得到加密字符串

4 将字符串替换到/root/.node-red/settings.js文件指定位置中,如下

    adminAuth: {
        type: "credentials",
        users: [{
            username: "dapenson",//改变登录用户名
            password: "$2b$08$Kfsos6Pmkrzv6Jx3vfk4xxxxxHxOrU/CY6FIH6XhM5mqFblVmK.",//将生成的密码填入此
            permissions: "*"
        }]
    },

设置NodeRED自启动

npm install pm2 -gd

pm2 start node-red

pm2 ls

sudo pm2 startup

sudo pm2 save

当你不需要使其自启动时,使用以下命令从pm2中删除该进程

pm2 delete nodered