小编use*_*121的帖子

nginx错误"冲突的服务器名称"被忽略

server {
    #listen   80; ## listen for ipv4; this line is default and implied
    #listen   [::]:80 default ipv6only=on; ## listen for ipv6

    #root /usr/share/nginx/www;

root /home/ubuntu/node-login;
    # Make site accessible from 
    server_name ec2-xx-xx-xxx-xxx.us-west-1.compute.amazonaws.com;

location /{
    proxy_pass http://127.0.0.1:8000/;
    proxy_redirect off;
}
Run Code Online (Sandbox Code Playgroud)

}

这导致nignx错误[警告]冲突的服务器名称"ec2 ..."在0.0.0.0:80忽略我不明白,任何解释赞赏.谢谢.

nginx

105
推荐指数
3
解决办法
16万
查看次数

nodeJS exec不适用于"cd"shell cmd

var sys = require('sys'),
    exec = require('child_process').exec;

exec("cd /home/ubuntu/distro", function(err, stdout, stderr) {
        console.log("cd: " + err + " : "  + stdout);
        exec("pwd", function(err, stdout, stderr) {
            console.log("pwd: " + err + " : " + stdout);
            exec("git status", function(err, stdout, stderr) {
                console.log("git status returned " ); console.log(err);
            })
        })
    })
Run Code Online (Sandbox Code Playgroud)
cd: null :

pwd: null : /

git status returned 
{ [Error: Command failed: fatal: Not a git repository (or any of the parent directories): .git ] …
Run Code Online (Sandbox Code Playgroud)

javascript exec node.js express

27
推荐指数
3
解决办法
2万
查看次数

在$ group中的mongodb聚合框架中使用$ regex

请考虑以下示例:

db.article.aggregate(
  { $group : {
      _id : "$author",
      docsPerAuthor : { $sum : 1 },
      viewsPerAuthor : { $sum : "$pageViews" }
  }}
);
Run Code Online (Sandbox Code Playgroud)

这个由作者字段分组并计算两个字段.

我有$ author = FirstName_LastName的值.现在不是按$ author分组,而是希望由共享相同LastName的所有作者进行分组.

我试过$ regex在'_'后按所有匹配的字符串分组

$author.match(/_[a-zA-Z0-9]+$/)

db.article.aggregate(
  { $group : {
      _id : "$author".match(/_[a-zA-Z0-9]+$/),
      docsPerAuthor : { $sum : 1 },
      viewsPerAuthor : { $sum : "$pageViews" }
  }}
);

also tried the following:

 db.article.aggregate(
  { $group : {
      _id : {$author: {$regex: /_[a-zA-Z0-9]+$/}},
      docsPerAuthor : { $sum : 1 },
      viewsPerAuthor …
Run Code Online (Sandbox Code Playgroud)

regex mongodb aggregation-framework

9
推荐指数
1
解决办法
1万
查看次数

mongodb聚合框架嵌套数组减去表达式

我有深层嵌套数组,我试图通过一些嵌套数组元素进行分组,并使其工作.但是,当我尝试使用$ subtract表达式时,它会失败.任何指针赞赏.

Data:

-scenes: [
  -{
     name: "Greeting_Excited"
     -records: [
          - {
              type: "listeningCycle"
              listeningId: 2
              timestamp: 1354566662041
              -events: [ … ]
              -timeProfile: {
              -timeStampInfo: {
                 earliestStamp: 1354566664530
                 latestStamp: 1354566678412
                }
               -timing: [
                  -{
                      start: 400
                      stop: 556
                      id: "SR-G"
                   }
                 -{
                      start: 559
                      stop: 572
                      id: "NL-G"
                  }
                 ]
                }
               }
             ]
          }
       ]

collection..aggregate( {$unwind:"$scenes"}, {$match: {'scenes.records.timeProfile.timing.id' : 'SR-G'}}, {$group: { _id : {segmentname: "$scenes.name"} , responsetimes : { $push : {$subtract : ["$scenes.records.timeProfile.timing.stop", "$scenes.records.timeProfile.timing.start"]} }}},  {$sort:{responsetimes:1}}   

I …
Run Code Online (Sandbox Code Playgroud)

mongodb node.js aggregation-framework

6
推荐指数
1
解决办法
5371
查看次数