我正在尝试在AWS代码部署中运行AfterInstall脚本,但它是从/ opt/codedeploy-agent/dir而不是我的app目录运行的.
这就是appspec.yml文件的样子:
version: 0.0
os: linux
files:
- source: /
destination: /tmp/epub
hooks:
AfterInstall:
- location: server/install-packages.sh
runas: root
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,这是一个基本的例子.
现在,bash脚本如下所示:
#!/bin/bash
npm install
Run Code Online (Sandbox Code Playgroud)
我只想安装npm,就是这样.
不幸的是我收到了错误:
LifecycleEvent - AfterInstall
Script - server/install-packages.sh
[stderr]npm ERR! install Couldn't read dependencies
[stderr]npm ERR! Linux 3.13.0-48-generic
[stderr]npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install"
[stderr]npm ERR! node v4.2.1
[stderr]npm ERR! npm v2.14.7
[stderr]npm ERR! path /opt/codedeploy-agent/package.json
[stderr]npm ERR! code ENOPACKAGEJSON
[stderr]npm ERR! errno -2
[stderr]npm ERR! syscall open
[stderr]
[stderr]npm ERR! package.json ENOENT: no such …Run Code Online (Sandbox Code Playgroud) 我以 GitHub 作为源创建了 AWS Code Pipeline。它工作正常,我能够毫无困难地从 GitHub 获取存储库。我已经通过这个管道部署了我的应用程序一百万次。
直到上周日(2015 年 11 月 15 日)我尝试发布对管道的更改。
从那时起我得到
GitHub 存储库“epub”不存在,或者提供的 GitHub 访问令牌没有足够的权限来访问存储库。验证存储库是否存在并编辑管道以将操作重新连接到 GitHub。
错误信息。
我已删除管道,撤销对 GitHub 上所有 AWS 服务的访问权限,从头开始创建管道,授予对 GitHub 上 AWS CodePipeline 应用程序的访问权限。我能够正确设置管道,当我在设置管道时连接到 GitHub 时,我能够获取所有存储库,并选择分支。
但在我运行管道后,我遇到了这个恼人的错误。
在我看来,这是一个 GitHub - AWS 访问问题,但我无法控制它,因为 GitHub 授权应用程序中的 AWS CodePipeline 控制它。
我现在正在尝试解决这个问题几天,但通过不同的教程和潜在的解决方案没有成功
有什么建议吗?
所以我有一个有趣的案例,即使用与Ajax调用的反应.
把它放在上下文中,我有一个带有3个标签的手风琴.初始化Accordion react组件后,我首先打开第一个标签,其余标签关闭.每个标签都有它的主体所谓的DictionaryCall组件,如下所示:
return class DictionaryCall extends React.Component {
constructor (props) {
super();
this.state = {
word: '',
data: [],
error: false,
nodata: false,
initialLoaded: props.load
}
}
componentDidMount () {
if(this.state.initialLoaded){
this.callAjax();
}
}
componentWillReceiveProps (nextProps) {
if(nextProps.load){
this.setState({initialLoaded: true});
this.callAjax();
}
}
callAjax () {
$.ajax({
url: this.props.url,
dataType: 'json',
catche: false,
method: 'POST',
data: {word: this.props.word},
success: function(data){
if(!data.length){
this.setState({nodata: true});
} else {
this.setState({data: data});
}
}.bind(this),
error: function(xhr, status, error){
console.log(this.props.url, status, error.toString());
this.setState({error: true}); …Run Code Online (Sandbox Code Playgroud) 我正在使用inversify与inversify-express-utils.
我有一个很平常的inversify/express设置。
B module是一个如下所示的类:
import { injectable } from 'inversify';
import SpellCorrector from 'spelling-corrector';
@injectable()
export class SpellCorrectorFactory {
private corrector: any;
constructor() {
this.corrector = new SpellCorrector();
this.corrector.loadDictionary();
}
public correct = (text: string): string => this.corrector.correct(text);
}
Run Code Online (Sandbox Code Playgroud)
现在,这里的问题是,正如您在构造函数中看到的,我有这行代码:
this.corrector.loadDictionary()
Run Code Online (Sandbox Code Playgroud)
该行需要一秒钟多的时间来执行。所以基本上看起来实际的实例创建是在我为服务提供服务@inject时发生的
所以每次我发出请求时,都会执行 的构造函数,因此请求需要超过 1000 毫秒而不是低于 100 毫秒。BASpellCorrectorFactory
如何将此类绑定到 inversify,以便在绑定期间实例化该类,并且在A module我可以访问在应用程序启动时创建的实例,而不是在我向快速路径发送请求时?
提前致谢!
我将一如既往地尽我所能,让我的问题变得甜美而干净。
我必须发送CORS作为需求请求,并且正在通过$ .ajax完成,它看起来像这样:
$.ajaxSetup({
beforeSend: function (jqXHR, options) {
options.url = Utils.setUrlHostname(options.url);
options.xhrFields = {
withCredentials: true
};
jqXHR.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
}
});
Run Code Online (Sandbox Code Playgroud)
在服务器端(php-zend框架),我正在处理标头,如下所示:
public function OPTIONS_ProxyAction()
{
$this->getResponse()->setHeader('Access-Control-Allow-Methods', 'OPTIONS, GET, POST, PUT, DELETE');
$this->getResponse()->setHeader('Access-Control-Allow-Headers', 'Content-Type, x-requested-with');
$this->getResponse()->setHeader('Access-Control-Allow-Credentials', 'true');
$this->getResponse()->setBody(null);
$this->_helper->viewRenderer->setNoRender(true);
}
Run Code Online (Sandbox Code Playgroud)
预检请求标头看起来很好,我得到200的确定:
请求标头:
Host: domain1111.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:38.0) Gecko/20100101 Firefox/38.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Origin: https://domain2222.com
Access-Control-Request-Method: GET (this is seen as OPTIONS in network tab)
Access-Control-Request-Headers: x-requested-with
Connection: keep-alive
Cache-Control: …Run Code Online (Sandbox Code Playgroud) javascript ×3
ajax ×2
bash ×1
cors ×1
express ×1
github ×1
inversifyjs ×1
jquery ×1
lifecycle ×1
node.js ×1
reactjs ×1
typescript ×1