Archive for 七月 2018

Elasticsearch 用systemctl启动报max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]

已经修改了/etc/security/limits.conf ,把数值加到65536,用elasticsearch用户启动,一切正常,但一旦用systemctl启动,还是报max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536] 而且,我的配置文件已经指定使用elasticsearch用户,诡异的错误。

其实出现这个问题,原因在于/etc/security/limits.conf里的配置只针对PAM认证登录用户有效,而Systemd有自己的一套配置。全局配置在/etc/systemd/system.conf和/etc/systemd/user.conf,也可以对单个服务做配置,所以,elasticsearch的脚本要做下修改:

[Unit]
Description=Elasticsearch

[Service]
Environment=JAVA_HOME=/usr/local/jdk1.8.0_171
LimitCORE=infinity
LimitNOFILE=65536
LimitNPROC=65536
ExecStart=/usr/local/elasticsearch-6.3.1/bin/elasticsearch
User=elasticsearch
Group=elasticsearch

[Install]
WantedBy=multi-user.target

Android Dialog弹出时不显示导航栏(沉浸式)

我们的app是全屏沉浸式的,发现activity在设置了全屏后,弹出dialog底部会跳出导航栏虚拟键。具体原因是因为Dialog的Window抢走了焦点,Window 中的 DecorView 状态改变导致了退出。
解决方法,在Dialog中:

   private void fullScreenImmersive(View view) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            int uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_FULLSCREEN;
            view.setSystemUiVisibility(uiOptions);
        }
    }

    @Override
    public void show() {
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
        super.show();
        fullScreenImmersive(getWindow().getDecorView());
        this.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
    }