我在javascript中有一个JSON对象.我想简单地将JSON对象写入文本文件.从目前为止我遇到的事情表明,由于客户端的安全问题,不可能这样做.有解决方法吗?如果最初放置一些虚拟值,是否可以修改已存在的文件?
谢谢
我在data.json文件中有如下JSON数据
[
{"original_name":"pdf_convert","changed_name":"pdf_convert_1"},
{"original_name":"video_encode","changed_name":"video_encode_1"},
{"original_name":"video_transcode","changed_name":"video_transcode_1"}
]
Run Code Online (Sandbox Code Playgroud)
我想迭代数组并提取循环中每个元素的值.我看到了jq.我发现很难用它来迭代.我怎样才能做到这一点?
我的服务中有以下代码
myService.ts
makeHttpGetRequest(url){
return Observable.interval(config.SUPERVISOR_REFRESH_INTERVAL * 1000)
.switchMap(() => this.http.get(url))
.map(res => res.json())
.timeout(config.REQUEST_TIMEOUT * 1000, new Error('Time out occurred'))
}
Run Code Online (Sandbox Code Playgroud)
在我的组件文件中
myComponent.ts
ngOnInit(){
this._myService.makeHttpGetRequest(myurl)
.subscribe(
data => {
this.supervisorServers = data;
}
},
error => {
this.error = true;
console.log(error); //gives an object at this point
this.showError(error);
}
);
}
Run Code Online (Sandbox Code Playgroud)
我想在例如Invailid url的情况下打印错误消息.当我打印错误时,我得到一个对象(可能是响应对象),如下所示:
Object { _body: error, status: 200, statusText: "Ok", headers: Object, type: 3, url: null }
Run Code Online (Sandbox Code Playgroud)
如果我打开它,我找不到错误信息.是否有更好的方法来获取precies错误消息?
我在Windows 7上使用nginx
版本1.10.3
.我想启用http2
.我在配置文件中添加了以下内容:
server {
listen 443 http2 ssl proxy_protocol;
}
Run Code Online (Sandbox Code Playgroud)
当我启动nginx服务器时,我收到以下错误:
2017/02/15 14:34:33 [emerg] 8948#6892: the "http2" parameter requires
ngx_http_v2_module in C:\Develop\Application\nginx-1.10.3/conf/nginx.conf:64
Run Code Online (Sandbox Code Playgroud)
行号64与上面指定的行相同.
如何ngx_http_v2_module
在Windows上安装?
我有以下代码
- set_fact:
MY_HOSTNAME: "SOME VALUE"
MY_SERVER: "00.00.00.00"
- name: Get MY server
set_fact:
MY_SERVER: "{{ groups[MY_HOSTNAME][0] }}"
when: groups[MY_HOSTNAME] is defined
Run Code Online (Sandbox Code Playgroud)
在上面的代码中,groups[MY_HOSTNAME]
是一个数组.什么是检查groups[MY_HOSTNAME]
定义的最佳方法,并且它是否是not empty
如果它是我想要00.00.00.00
分配值的任何一个MY_SERVER
我有以下代码在AngularJS 2中进行轮询GET请求:
makeHtpGetRequest(){
let url ="http://bento/supervisor/info";
return Observable.interval(2000)
.map(res => res.json()) //Error here
.switchMap(() => this.http.get(url));
/*
This portion works well
return this.http.get(url)
.map(res =>res.json());*/
}
Run Code Online (Sandbox Code Playgroud)
TypeScript给我一个错误,以JSON格式制作响应(检查代码中的注释.
TypeError: res.json is not a function
Run Code Online (Sandbox Code Playgroud)
令人惊讶的是,它工作了一段时间,我不确定我是否改变了其他任何东西,但它停止了工作.
代码中的注释部分非常有效.
这个问题之前已经被问过很多次了,但是我的 php.ini 文件似乎不存在。
我通过在 Amazon Linux 机器上从源代码编译安装了 php 5.6.2。看来安装得很好。
which php
给出
/usr/local/bin/php
Run Code Online (Sandbox Code Playgroud)
php --ini
给出
Configuration File (php.ini) Path: /usr/local/lib
Loaded Configuration File: (none)
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
Run Code Online (Sandbox Code Playgroud)
当我输入时/usr/local/lib
,没有 php.ini 存在。我应该自己创建一个新的 php.ini 文件吗?
我istio v1.1.1
使用可用的舵图进行安装。
我有
$ kubectl get svc istio-ingressgateway -n istio-system
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
istio-ingressgateway LoadBalancer 10.31.251.20 35.189.53.230 80:31380/TCP,443:31390/TCP,31400:31400/TCP,15029:31920/TCP,15030:32305/TCP,15031:31084/TCP,15032:31163/TCP,15443:32714/TCP,15020:30964/TCP 3h
Run Code Online (Sandbox Code Playgroud)
然后,我创建了一个网关和虚拟服务,如下所示:
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: myservice-gateway
namespace: stg
spec:
selector:
istio: ingressgateway # use Istio default gateway implementation
servers:
- hosts:
- "stg.myservice.com"
port:
number: 80
protocol: http
name: http-myservice-port
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: myservice
namespace: stg
spec:
hosts:
- "stg.myservice.com"
gateways:
- myservice-gateway
http:
- match:
- uri:
prefix: / …
Run Code Online (Sandbox Code Playgroud) 我在 Google Kubernetes 集群上启用了自动缩放,并且我可以看到其中一个 Pod 的使用率要低得多
我总共有 6 个节点,我预计至少有这个节点被终止。我已经完成了以下操作: https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/FAQ.md#what-types-of-pods-can-prevent-ca-from-removing-a -节点
我已将此注释添加到我的所有 pod 中
cluster-autoscaler.kubernetes.io/safe-to-evict: true
Run Code Online (Sandbox Code Playgroud)
但是,集群自动缩放程序可以正确扩展,但不会像我预期的那样缩小。
我有以下日志
$ kubectl logs kube-dns-autoscaler-76fcd5f658-mf85c -n kube-system
autoscaler/pkg/autoscaler/k8sclient/k8sclient.go:90: Failed to list *v1.Node: Get https://10.55.240.1:443/api/v1/nodes?resourceVersion=0: dial tcp 10.55.240.1:443: getsockopt: connection refused
E0628 20:34:36.187949 1 reflector.go:190] github.com/kubernetes-incubator/cluster-proportional-autoscaler/pkg/autoscaler/k8sclient/k8sclient.go:90: Failed to list *v1.Node: Get https://10.55.240.1:443/api/v1/nodes?resourceVersion=0: dial tcp 10.55.240.1:443: getsockopt: connection refused
E0628 20:34:47.191061 1 reflector.go:190] github.com/kubernetes-incubator/cluster-proportional-autoscaler/pkg/autoscaler/k8sclient/k8sclient.go:90: Failed to list *v1.Node: Get https://10.55.240.1:443/api/v1/nodes?resourceVersion=0: net/http: TLS handshake timeout
I0628 20:35:10.248636 1 autoscaler_server.go:133] ConfigMap not found: Get https://10.55.240.1:443/api/v1/namespaces/kube-system/configmaps/kube-dns-autoscaler: net/http: TLS …
Run Code Online (Sandbox Code Playgroud) 我在 github actions 中运行以下代码
- name: Verify Workflow integrity
run: |
echo "some text" > test/apps/test/test.yml
cat test/apps/test/test.yml
echo "${{ hashFiles('test/apps/test/*.yml') }}"
echo "alter text" > test/apps/test/test.yml
cat test/apps/test/test.yml
echo "${{ hashFiles('test/apps/test/*.yml') }}"
Run Code Online (Sandbox Code Playgroud)
它产生以下输出
| some text
| e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
| alter text
| e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
Run Code Online (Sandbox Code Playgroud)
由于文件中的文本已更改,我期待不同的哈希值。然而,它产生相同的哈希值。我错过了什么吗?
test/apps/test
基本上,我想找到目录中所有文件的哈希值
json ×3
angular ×2
ansible ×1
autoscaling ×1
bash ×1
gateway ×1
hash ×1
http ×1
http2 ×1
istio ×1
javascript ×1
jq ×1
kubernetes ×1
linux ×1
nginx ×1
observable ×1
php ×1
rxjs ×1