我对AWS Beanstalk部署的整体工作流程很好奇.我假设它在某些时候运行npm以获得在服务器上安装的软件包.但我只是想知道AWS Beanstalk是否使用'npm install --production'的最新命令来安装软件包.目前我有一个如下所示的packages.json文件,并且如果可能的话,我想确保只安装依赖项而不是devDependencies.
"dependencies": {
"express": "3.4.4",
"jade": "*",
"restify": "~2.6.0",
"assert": "~1.0.0",
"orchestrate": "0.0.2",
"chance": "~0.5.3"
},
"devDependencies": {
"mocha": "~1.15.1"
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试为进入Hapi处理程序的JSON对象编写Joi验证.到目前为止代码看起来像这样:
server.route({
method: 'POST',
path: '/converge',
handler: function (request, reply) {
consociator.consociate(request.payload)
.then (function (result) {
reply (200, result);
});
},
config: {
validate: {
payload: {
value: Joi.object().required().keys({ knownid: Joi.object() })
}
}
}
});
Run Code Online (Sandbox Code Playgroud)
到目前为止,您可以在上面的config:validate:code部分中看到Joi对象验证.进入的JSON看起来像这样.
"key": '06e5140d-fa4e-4758-8d9d-e707bd19880d-testA',
"value": {
"ids_lot_args": {
"this_id": "stuff",
"otherThign": "more data"
},
"peripheral_data": 'Sample peripheral data of any sort'
}
Run Code Online (Sandbox Code Playgroud)
在上面的JSON中,需要对象根目录的键和值,并且ids_lot_args需要调用的部分.以peripheral_data开头的部分可以在那里,也可以是任何其他JSON有效负载.没关系,只ids_lot_args需要根级别和值内部的键和值.
到目前为止,我一直在努力让Joi验证工作. 有关如何设置的任何想法?Joi的代码仓库位于https://github.com/hapijs/joi,如果想要查看它.到目前为止,我一直在尝试允许对象上的所有函数无效.
我用以下代码构建了一个非常简单的hapi.js应用程序.
var Hapi = require('hapi');
var server = new Hapi.Server(3000);
server.route({
method: 'GET',
path: '/',
handler: function (request, reply) {
reply('Hello, world!');
}
});
server.start(function () {
console.log('Server running at:', server.info.uri);
});
Run Code Online (Sandbox Code Playgroud)
但是,部署时我不断收到"502 Bad Gateway"错误.我正在使用标准的zip和上传方法进行部署.zip文件包含一个带有上述代码的service.js文件和一个package.json文件,如下所示.
{
"name": "hapi_aws_testing",
"version": "0.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"hapi": "^6.4.0"
},
"engines" : {
"node": "0.10.26"
}
}
Run Code Online (Sandbox Code Playgroud)
我已经尝试删除node.js引擎部分进行部署,并将其设置为0.10.29,然后意识到1.0.4 AMI图像上Beanstalk中可用的node.js版本为0.10.26,所以更改了它这个版本.我在当地尝试过,一切运行良好.
在错误日志中,我有以下两个日志显示正在运行的代码...
-------------------------------------
/var/log/nodejs/nodejs.log
-------------------------------------
Server running …Run Code Online (Sandbox Code Playgroud) 我有两个环境变量.一个是TF_VAR_UN另一个是TF_VAR_PW.然后我有一个看起来像这样的terraform文件.
resource "google_container_cluster" "primary" {
name = "marcellus-wallace"
zone = "us-central1-a"
initial_node_count = 3
master_auth {
username = ${env.TF_VAR_UN}
password = ${env.TF_VAR_PW}
}
node_config {
oauth_scopes = [
"https://www.googleapis.com/auth/compute",
"https://www.googleapis.com/auth/devstorage.read_only",
"https://www.googleapis.com/auth/logging.write",
"https://www.googleapis.com/auth/monitoring"
]
}
}
Run Code Online (Sandbox Code Playgroud)
这两个值我想用环境变量替换TF_VAR_UN和TF_VAR_PW是值的用户名和密码.我尝试了上面显示的内容,没有成功,我玩弄了一些其他的东西,但总是得到语法问题.
我一直在为Visual Studio创建一个完整的垂直堆栈模板(如果你想帮忙的话,它就在Github上:https: //github.com/Adron/infrastructure
我的问题是,我无法在解决方案的根目录中为程序集添加文件夹.单个项目模板(我在整个父解决方案模板中有三个)具有许多单独的元素,例如文件和文件夹.但是当我尝试向父模板添加类似内容时,它会报告它在此XML模式/文件中无效.
我当前的解决方案XML文件如下所示:
<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="ProjectGroup">
<TemplateData>
<Name>ASP.NET MVC 3 + Razor + Machine.Specifications Infrastructure Solution</Name>
<Description>This Visual Studio Template provides the following pieces for getting a kick start when building well designed web sites using good patterns.</Description>
<EnableEditOfLocationField>true</EnableEditOfLocationField>
<EnableLocationBrowseButton>true</EnableLocationBrowseButton>
<ProvideDefaultName>true</ProvideDefaultName>
<Icon>Icon.ico</Icon>
<ProjectType>CSharp</ProjectType>
<SortOrder>1000</SortOrder>
<CreateNewFolder>true</CreateNewFolder>
<DefaultName>Infrastructure</DefaultName>
<LocationField>Enabled</LocationField>
<PreviewImage>Preview.png</PreviewImage>
</TemplateData>
<TemplateContent>
<ProjectCollection>
<ProjectTemplateLink ProjectName="Infrastructure.Web">Web\MyTemplate.vstemplate</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="Infrastructure.Specifications">Specifications\MyTemplate.vstemplate</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="Infrastructure.Data">Data\MyTemplate.vstemplate</ProjectTemplateLink>
</ProjectCollection>
</TemplateContent>
</VSTemplate>
Run Code Online (Sandbox Code Playgroud)
有关如何添加文件夹或个人资产的任何想法?谢谢...
我有一个Node.js CLI,我一直在使用Commander Library 构建.这是主执行文件中的代码.
#!/usr/bin/env node
var program = require('commander');
var scmStash = require('./lib/hdqc/scmStash');
var command = {};
program
.version('0.0.1')
.option('-P, --Projects', 'List Projects')
.option('-R, --Repositories', 'List All Repositories on Server.')
.parse(process.argv);
function listProjects() {
scmStash.getProjectListing(function (data) {
for (var i = 0; i < data.size; i++) {
var project = data.values[i];
console.log(' ' + i + ' ' + project.name + ' @ ' + project.link.url);
}
})
}
if (program.Projects) {
console.log(' - Projects');
listProjects();
}
Run Code Online (Sandbox Code Playgroud)
我一直在WebStorm中构建它,当我使用node.js调用命令时,一切运行完美.例如,如果我运行WebStorm运行程序执行./strack …
我正在尝试使用该调用编写asynchronous测试。到目前为止,这是我的代码。mochadone();
it('should have data.', function () {
db.put(collection, key, json_payload)
.then(function (result) {
result.should.exist;
done();
})
.fail(function (err) {
err.should.not.exist;
done();
})
})
Run Code Online (Sandbox Code Playgroud)
但是,结果是代码仅在不等待 then的情况下执行,否则将无法真正返回结果。是否done();需要在代码中的其他位置?
还在此处发布了整个仓库:https : //github.com/Adron/node_testing_testing
在构建Windows服务时,有没有人有使用TopShelf的经验?
尝试启动服务时,我一直遇到此错误,
"尚未安装Topshelf.HostConfigurators.WindowsServiceDescription服务."
完成构建,安装程序,安装和所有这些步骤,并且该服务显示在Windows Server的服务列表中,但是当我单击该服务并尝试启动它时,将抛出此异常.完整的错误消息如下所示.
INFO 10:23:08作为winservice应用程序启动FATAL 10:23:08 Topshelf.HostConfigurators.WindowsServiceDescription服务尚未安装.请运行'RIS.ModelGenerator.Scheduler,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null install'.错误10:23:08服务异常退出并出现异常Topshelf.Exceptions.ConfigurationException:Topshelf.HostConfigurators.WindowsServiceDescription服务尚未安装.请运行'RIS.ModelGenerator.Scheduler,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null install'.在d:\ BuildAgent-01\work\799c08e77fef999d\src\Topshelf\OS\Windows\WindowsServiceHost.cs中的Topshelf.Windows.WindowsServiceHost.Run()中:在Topshelf.HostFactory.Run(Action`1 configure)中的第56行:\ BuildAgent-01\work\799c08e77fef999d\src\Topshelf\Config\HostFactory.cs:第45行
我正在使用 Terraform 设置远程后端来管理状态。I\xe2\x80\x99ve 设置了一个 connection.tf 文件,用于连接和声明 Terraform 状态文件的 GCS。文件内容如下所示。
\n\nprovider "google" {\n credentials = "${file("../../secrets/account-thrashingcode.json")}"\n project = "thrashingcorecode"\n region = "us-west1"\n}\n\nterraform {\n backend "gcs" {\n bucket = "terraform-remote-states"\n path = "dev/terraform.tfstate"\n project = "thrashingcorecode"\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n\n资源 I\xe2\x80\x99ve 设置(至少对于本示例而言)是在 GCP 中创建默认网络的超级简单配置。该配置看起来像这样。
\n\ndata "google_compute_network" "my-network" {\n name = "default-us-west1"\n}\nRun Code Online (Sandbox Code Playgroud)\n\n现在,当我运行 terraform init 时,出现此错误。
\n\n$ terraform init\n\nInitializing the backend...\n\nSuccessfully configured the backend "gcs"! Terraform will automatically\nuse this backend unless the backend configuration changes.\nError refreshing state: [WARN] Error retrieving …Run Code Online (Sandbox Code Playgroud) javascript ×4
node.js ×3
asynchronous ×2
hapijs ×2
terraform ×2
bash ×1
json ×1
mocha.js ×1
npm ×1
service ×1
testing ×1
topshelf ×1
validation ×1
windows ×1