问题描述
slc pm 启动的时候报错如下:
[root@iZuf61qpjpeuqc5mjo4kn8Z lixiang-scf-web]# slc pm
strong-remoting deprecated The built-in CORS middleware provided by REST adapter was deprecated. See https://docs.strongloop.com/display/public/LB/Security+considerations for more details. ../../../../app/node-v6.9.5-linux-x64/lib/node_modules/strongloop/node_modules/_strong-remoting@2.35.1@strong-remoting/lib/remote-objects.js:97:25
slc pm(4457) Unexpected end of JSON input
[root@iZuf61qpjpeuqc5mjo4kn8Z strongloop]# slc pm --json-file-db
strong-remoting deprecated The built-in CORS middleware provided by REST adapter was deprecated. See https://docs.strongloop.com/display/public/LB/Security+considerations for more details. ../node-v6.9.5-linux-x64/lib/node_modules/strongloop/node_modules/_strong-remoting@2.35.1@strong-remoting/lib/remote-objects.js:97:25
events.js:160
throw er; // Unhandled 'error' event
^
Error: SQLITE_FULL: database or disk is full
at Error (native)
[root@iZuf61qpjpeuqc5mjo4kn8Z strongloop]#
定位问题:
node-v6.9.5-linux-x64/lib/node_modules/strongloop/node_modules/_strong-remoting@2.35.1@strong-remoting/lib/remote-objects.js
查看文件:remote-objects.js
设置显示行号:97行
94 RemoteObjects.prototype.handler = function(name, options) {
95 var Adapter = this.adapter(name);
96 var adapter = new Adapter(this, options);
97 var handler = adapter.createHandler();
98
99 if (handler) {
100 // allow adapter reference from handler
101 handler.adapter = adapter;
102 }
103
104 return handler;
105 };
原因分析
- 在上一次系统部署后,包括后台+ 前台 在同一台服务器上,初步怀疑是strongloop出现异常
尝试卸载strongloop
使用命令npm uninstall -g strongloop
报错磁盘空间不足,发现问题后台异常日志将系统填满,
使用du -sh *
查找磁盘空间写满目录,rm -rf *
删除异常空间目录
- 重新启动新的错误
[root@iZuf61qpjpeuqc5mjo4kn8Z strongloop]# tailf nohup.out
events.js:160
throw er; // Unhandled 'error' event
^
SyntaxError: Unexpected end of JSON input
at Object.parse (native)
at parseAndLoad (/app/node-v6.9.5-linux-x64/lib/node_modules/strongloop/node_modules/_loopback-datasource-juggler@2.58.0@loopback-datasource-juggler/lib/connectors/memory.js:129:21)
at /app/node-v6.9.5-linux-x64/lib/node_modules/strongloop/node_modules/_loopback-datasource-juggler@2.58.0@loopback-datasource-juggler/lib/connectors/memory.js:115:9
at tryToString (fs.js:455:3)
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:442:12)
# 文件内容:/app/node-v6.9.5-linux-x64/lib/node_modules/strongloop/node_modules/_loopback-datasource-juggler@2.58.0@loopback-datasource-juggler/lib/connectors/memory.js:115:9
105 Memory.prototype.loadFromFile = function(callback) {
106 var self = this;
107 var hasLocalStorage = typeof window !== 'undefined' && window.localStorage;
108 var localStorage = hasLocalStorage && this.settings.localStorage;
109
110 if (self.settings.file) {
111 fs.readFile(self.settings.file, {encoding: 'utf8', flag: 'r'}, function(err, data) {
112 if (err && err.code !== 'ENOENT') {
113 callback && callback(err);
114 } else {
115 parseAndLoad(data);
116 }
通过修改源码,找到对应的配置文件:
Memory.prototype.loadFromFile = function(callback) {
106 var self = this;
107 var hasLocalStorage = typeof window !== 'undefined' && window.localStorage;
108 var localStorage = hasLocalStorage && this.settings.localStorage;
109
110 if (self.settings.file) {
111 fs.readFile(self.settings.file, {encoding: 'utf8', flag: 'r'}, function(err, data) {
112 if (err && err.code !== 'ENOENT') {
113 callback && callback(err);
114 } else {
115 console.log(self.settings.file);
116 parseAndLoad(data);
117 }
118 });
119 } else if (localStorage) {
120 var data = window.localStorage.getItem(localStorage);
121 data = data || '{}';
122 parseAndLoad(data);
123 } else {
124 process.nextTick(callback);
125 }
126
127 function parseAndLoad(data) {
128 if (data) {
129 try {
130 console.log(data)
131 data = JSON.parse(data.toString());
132 } catch (e) {
133 return callback(e);
134 }
配置文件地址:/root/.strong-pm/
里面的所有配置json
解决方案:
删除/root/.strong-pm/
中的配置文件,启动后重新生成,通过命令配置心得环境变量
/root/.strong-pm/strong-pm.json
备份后删除即可。
重新配置环境变量
slc ctl env-set svc xxx=xxx
参考
官网地址:http://strong-pm.io/