我正在尝试对远程服务器进行简单的Rails/Capistrano部署.不幸的是,我无法sudo开箱即用.我需要在这里部署:
drwxr-xr-x 2 user www 4096 Sep 28 15:05 my_app_dir
Run Code Online (Sandbox Code Playgroud)
和sudoers已经设置允许我运行sudo su - user,就是这样.
有些尝试从deploy.rb中哄骗这个:
set :use_sudo, true
set :sudo, 'sudo su - user' # fails due to bad su syntax, -c is inserted after user
set :sudo, 'sudo -u user' # fails because it's not set up
set :sudo, 'sudo su - user -c' # also bad syntax
set :sudo_prompt, ''
Run Code Online (Sandbox Code Playgroud)
我认为最好的选择是:
sudo(此处推荐)sudo -u user,应该使用set :sudo, 'sudo …谷歌的cAdvisor API提供如下JSON输出:
{
/system.slice/docker-13b18253fa70d837e9707a1c28e45a3573e82751f964b66d7c4cbc2256abc266.scope: {},
/system.slice/docker-747f797d19931b4ef33cda0c519f935b592a0b828d16b8cafc350568ab2c1d28.scope: {},
/system.slice/docker-bf947bfabf61cd5168bd599162cf5f5c2ea2350eece1ded018faebf598f7ee5b.scope: {},
/system.slice/docker-e8e02d508400438603151dd462ef036d59fada8239f66be8e64813880b59a77d.scope: {
name: "/system.slice/docker-e8e02d508400438603151dd462ef036d59fada8239f66be8e64813880b59a77d.scope",
aliases: [...],
namespace: "docker",
spec: {...},
stats: [...]
}
}
Run Code Online (Sandbox Code Playgroud)
我将此描述为具有变量/匿名名称的4个相同类型的JSON对象,保存在匿名对象中.
我的第一个想法就是做一些事情mapper.readValue(response, Containers.class),其中:
public class Containers extends BaseJsonObject {
@JsonProperty
public List<Container> containerList;
}
Run Code Online (Sandbox Code Playgroud)
和
public class Container extends BaseJsonObject {
@JsonProperty
private String name;
@JsonProperty
public String[] aliases;
@JsonProperty
private String namespace;
@JsonProperty
private String spec;
@JsonProperty
public Stats[] stats;
}
Run Code Online (Sandbox Code Playgroud)
但是,所有关于这个我能想到的产生相同的结果的变化:部分置换com.xyz.Containers@45c7e403[containerList=<null>]或com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "/system.slice/docker-13b18253fa70d837e9707a1c28e45a3573e82751f964b66d7c4cbc2256abc266.scope" (class com.xyz.Containers), not marked as ignorable …
我正在尝试在隔离的类加载器中运行groovy脚本,以便它们不会在调用类的依赖项的上下文中执行.
Path log4j = Paths.get("..../lib/log4j-1.2.17.jar");
Path groovy = Paths.get("..../lib/groovy-all-2.1.3.jar");
RootLoader rootLoader = new RootLoader(new URL[] { log4j.toUri().toURL(), groovy.toUri().toURL() }, null);
GroovyScriptEngine engine = new GroovyScriptEngine(".../src/main/resources", rootLoader);
engine.run("Standalone.groovy", "");
Run Code Online (Sandbox Code Playgroud)
Standalone.groovy:
import org.apache.log4j.BasicConfigurator
import org.apache.log4j.Logger
Logger logger = Logger.getLogger(getClass())
BasicConfigurator.configure()
logger.info("hello world")
Run Code Online (Sandbox Code Playgroud)
pom.xml摘录:
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.1.3</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我试过的上述任何变化都会导致
Exception in thread "main" groovy.lang.GroovyRuntimeException: Failed to create Script instance for class: class Standalone. Reason: java.lang.ClassCastException: Standalone cannot be cast to groovy.lang.GroovyObject
at org.codehaus.groovy.runtime.InvokerHelper.createScript(InvokerHelper.java:443)
at groovy.util.GroovyScriptEngine.createScript(GroovyScriptEngine.java:564)
at groovy.util.GroovyScriptEngine.run(GroovyScriptEngine.java:551)
at groovy.util.GroovyScriptEngine.run(GroovyScriptEngine.java:537) …Run Code Online (Sandbox Code Playgroud) 考虑
int a = 20;
a = a + (a = 5); // a == 25, why not 10?
Run Code Online (Sandbox Code Playgroud)
请问括号是否胜过所有优先规则?在评估某些表达式之前,RHS是否预先填充了某些变量?
如果匿名类正在扩展/实现类/接口,为什么我不能添加新方法?
换句话说,这有效:
class A {
void a() {
System.out.println("a in A");
}
}
class B extends A {
@Override
void a() {
System.out.println("a in B");
}
void b() {
System.out.println("b in B");
}
}
Run Code Online (Sandbox Code Playgroud)
为什么这不起作用:
class C {
A anonA() {
return new A() {
void b() {
System.out.println("b in C");
}
};
}
}
Run Code Online (Sandbox Code Playgroud)
鉴于:
public static void main(String[] args) {
B b = new B();
b.b();
// C c = new C();
// A anonA = c.anonA();
// …Run Code Online (Sandbox Code Playgroud) 发现了一些小错别字,例如:
<rollback>
<delete tableName="velocity_template">
<where>id in ("from-address.vm", "myco.from-address.vm")</where>
</delete>
</rollback>
Run Code Online (Sandbox Code Playgroud)
到
<rollback>
<delete tableName="velocity_template">
<where>id in ('from-address.vm', 'myco.from-address.vm') </where>
</delete>
</rollback>
Run Code Online (Sandbox Code Playgroud)
是否可以在不需要回滚并重新应用变更集的情况下纠正这些问题?
这里的文档没有以某种方式具体说明有关回滚块的任何内容: http://www.liquibase.org/2009/03/what-effects-changeset-checksums.html
我的本地测试表明回滚块不是校验和计算的一部分。
鉴于values.yaml:
outer:
inner:
someKey: false
Run Code Online (Sandbox Code Playgroud)
helm 模板文件中的以下语法是什么意思?
{{- if index (default (dict) .Values.outer.inner) "someKey" }}
{{- .... }}
{{- end }}
Run Code Online (Sandbox Code Playgroud)
从上下文中,我可以推断出我认为它应该做什么:检查指定的密钥是否存在于指定的位置。
但default (dict)...语法从何而来?小枝?我在这些地方都找不到它的记录:
https://v2.helm.sh/docs/chart_template_guide/#template-functions-and-pipelines
https://golang.org/pkg/text/template/#hdr-Functions
http://masterminds.github.io/sprig/
http://masterminds.github.io/sprig/defaults.html
它到底意味着什么?
我正在尝试添加配置参数,deploy.rb以便pggem正确构建:
before "bundle:install" do
run "ls -l #{fetch(:latest_release)}/Gemfile"
run "bundle config --local --gemfile=#{fetch(:latest_release)}/Gemfile build.pg --with-pg-config=/usr/pgsql-9.1/bin/pg_config"
end
Run Code Online (Sandbox Code Playgroud)
在输出中,添加的诊断代码清楚地显示了非空Gemfile的存在:
* executing `bundle:install'
triggering before callbacks for `bundle:install'
* executing "ls -l /apps/my_app/releases/20121008195429/Gemfile"
servers: ["my_server.com"]
[my_server.com] executing command
** [out :: my_server.com] -rw-r--r-- 1 webapp webapp 1291 Oct 5 22:34 /apps/my_app/releases/20121008195429/Gemfile
command finished in 157ms
* executing "bundle config --local --gemfile=/apps/my_app/releases/20121008195429/Gemfile build.pg --with-pg-config=/usr/pgsql-9.1/bin/pg_config"
servers: ["my_server.com"]
[my_server.com] executing command
** [out :: my_server.com] Could not locate Gemfile
Run Code Online (Sandbox Code Playgroud)
如果我使用--global副词,我会得到相同的结果 …
这是我在Activity后代中覆盖on*方法的图片.

为什么IntelliJ/AS没有尝试猜测,因为当我输入其他任何东西时呢?
在设置中我没有看到任何明显的取消选择:
