简体   繁体   English

解析云代码未执行指定任务,并且未创建日志

[英]parse cloud code is not performing designated task and no log is created

my afterSave cloud code should run after each save, but i don't see it performing the task. 我的afterSave云代码应在每次保存后运行,但我看不到它执行任务。 also no debug info is written to a local "temp.txt" file 也没有将调试信息写入本地“ temp.txt”文件

My parse server is running on docker container (maybe it's relevant) I did a do a clean docker run (to launch the parse server) after the main.js was created in the /parse-server/cloud subfolder , but still not seeing anything 我的解析服务器在docker容器上运行(可能是相关的),在/ parse-server / cloud子文件夹中创建了main.js之后,我做了一个干净的docker 运行 (以启动解析服务器),但是仍然看不到任何内容

how can i debug this cloud-code issue ? 我如何调试此云代码问题?

my main.js content: 我的main.js内容:

Parse.Cloud.afterSave("Post", (request) => {
var fs = require("fs");
    const image = request.object.get("image").url();
    const detail  = request.object.get("detail");
    const geo = request.object.get("geo");
    const itemId = request.object.get("objectId");
fs.writeFileSync('./temp.txt', request, function(err, data) {
  if (err) console.log(err);
});

    console.log(detail);
    console.log(image);
    console.log(geo);
    console.log('========');

var data =detail+" "+image+" "+geo+" "+request;

fs.appendFileSync("./temp.txt", data, function(err, data) {
  if (err) console.log(err);
  console.log("Successfully Written to File.");
});

    var postRequest = require('request');
    postRequest({
      method: 'POST',
      preambleCRLF: true,
      postambleCRLF: true,
      json: true,
      uri: 'https://graph.facebook.com/1111/feed?access_token=sometoken',
      body:
        {
          message: detail,
          link: image
        }
    },
    function (error, response, body) {
      if (error) {
        return console.error('upload failed:', error);
        console.log('statusCode:', response && response.statusCode);
        fs.appendFileSync("temp.txt", response+" "+ response.statusCode
                ,function(err, data) {
                       if (err) console.log(err);
                });
      }
      console.log('Upload successful!  Server responded with:', body);
    })

  }
);

when launching parse docker container (using "docker run" for example) we must also pass " The absolute path to our cloud code main.js file." 当启动解析 docker容器时(例如,使用“ docker run”),我们还必须传递“ 云代码main.js文件的绝对路径。” (including the main.js) (包括main.js)

for example: 例如:

sudo docker run  --name parse --network=test  --appId <app-id> --masterKey <mater-key>--publicServerURL https://my-url.com/parse --databaseURI mongodb://mongo:port/mongo --cloud /parse-server/<cloudpath>/main.js 

the missing switch inside the " docker run " command here was: 此处的“ docker run ”命令中缺少的开关是:

--cloud /parse-server/cloudpath/main.js --cloud /parse-server/cloudpath/main.js

this resolved the issue 这解决了问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM