yarn install consumes all memory on TeamCity and Jenkins

偶尔善良 提交于 2021-02-11 12:29:21

问题


I'd really like to get yarn working with TeamCity or Jenkins, however yarn install consumes all my build server's cpu & memory, even with a tiny npm project. Any idea why?

Summary

  • yarn install, when run by TeamCity or Jenkins, consumes most CPU/memory, never finishes
  • running yarn install from the command line on the build server works (finishes in a few seconds)
  • npm install completes in a few seconds when run by TeamCity/Jenkins
  • build server: Windows Server 2012, 2 cores, 4GB mem
  • yarn version 1.6.0
  • Jenkins version 2.107.2
  • TeamCity version 2017.2.3
  • Have tried Node.js versions 8.11.1 and 9.11.1

Details

Steps:

Create a tiny npm project:

mkdir temp
cd temp
yarn init  # all defaults
yarn add dummy-module  # tiny test package

Commit this to git, set up a Jenkins or TeamCity build with a single command yarn install.

The build never finishes, with the last line of console output: yarn install v1.6.0. At this time, the Node.js process is consuming most of the CPU and memory on the build machine. Changing the command to npm install makes it run successfully.

Since it's common to Jenkins and TeamCity, it seems like the problem is to do with running sub processes from java. I can't find any indication of what's going wrong in either the TeamCity or Jenkins logs. When aborting the Jenkins build, I see the following in jenkins.err.log:

Apr 22, 2018 8:59:11 AM hudson.model.Run execute
INFO: master-cake #9 aborted
java.lang.InterruptedException
    at java.lang.ProcessImpl.waitFor(Unknown Source)
    at hudson.Proc$LocalProc.join(Proc.java:324)
    at hudson.tasks.CommandInterpreter.join(CommandInterpreter.java:155)
    at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:109)
    at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:66)
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
    at hudson.model.Build$BuildExecution.build(Build.java:206)
    at hudson.model.Build$BuildExecution.doRun(Build.java:163)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504)
    at hudson.model.Run.execute(Run.java:1727)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:429)

回答1:


I left some crucial information out of the original question - I'm also using yarn's offline mirror, which was stored on a network drive. It turns out that the TeamCity windows service can't access network drives: https://confluence.jetbrains.com/display/TCD10/Known+Issues#KnownIssues-AgentrunningasWindowsServiceLimitations

Relocating yarn's offline mirror to a local directory solved the issue for both TeamCity and Jenkins.



来源:https://stackoverflow.com/questions/49961323/yarn-install-consumes-all-memory-on-teamcity-and-jenkins

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!