Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy server processes often die #23789

Closed
zhaogeyuan opened this issue Jan 20, 2020 · 0 comments
Closed

Proxy server processes often die #23789

zhaogeyuan opened this issue Jan 20, 2020 · 0 comments
Labels

Comments

@zhaogeyuan
Copy link

@zhaogeyuan zhaogeyuan commented Jan 20, 2020

I use two proxy services, anyproxy and tinyproxy. They are deployed on 6 servers respectively, and the problem that the proxy process will die after running for a while. I use a java program to call youtube-dl through a shell command to download audio
` try {

            // 执行命令, 返回一个子进程对象(命令在子进程中执行)
            process[0] = Runtime.getRuntime().exec(cmd, null, dir);

            // 获取命令执行结果, 有两个结果: 正常的输出 和 错误的输出(PS: 子进程的输出就是主进程的输入)
            bufrIn[0] = new BufferedReader(new InputStreamReader(process[0].getInputStream(), "UTF-8"));
            bufrError[0] = new BufferedReader(new InputStreamReader(process[0].getErrorStream(), "UTF-8"));

            // 读取输出
            String line = null;
            while ((line = bufrIn[0].readLine()) != null) {
                result.append(line).append('\n');
            }
            while ((line = bufrError[0].readLine()) != null) {
                result.append(line).append('\n');
            }

            // 方法阻塞, 等待命令执行完成(成功会返回0)
            int code = process[0].waitFor();

        } catch (Exception e) {

            logger.error("thread pool run shell command fail.",e);

        }`
@dstftw dstftw closed this Jan 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.