这是发生的事情:我用堆栈构建了一个docker映像,但是该过程被中断了五次。该消息说,每次中断都是在构建软件包Cabal-2.4.1.0时发生的。该过程已退出,代码为:#[macro_use]
extern crate serde;
。
我想在docker-script中自动执行该过程,因此将堆栈放到最后是至关重要的。那是我的问题。这是不时进行构建时发生的事情(我省略了一些行以使滚动保持在合理的范围内,因此希望看到ExitFailure (-9) (THIS MAY INDICATE OUT OF MEMORY)
)。 (待在底部继续。)
<... skipping <n> lines ...>
奇怪的是,由于(可能的)内存耗尽原因而中断了构建过程,但是在重新启动docker-build进程后,该过程愉快地继续了。我需要重启5次才能结束。
我尝试通过以下命令来增加docker的内存:
BA92-C02VP224HTDF:Ampersand stefjoosten$ docker build -t amp:latest .
Sending build context to Docker daemon 70.28MB
Step 1/8 : FROM ubuntu:latest
---> 7698f282e524
Step 2/8 : RUN apt-get update && apt-get --yes install curl && apt-get --yes install git-core
---> Using cache
---> 81322e02eb2a
Step 3/8 : RUN curl -sSL https://get.haskellstack.org/ | sh # install Haskell and stack
---> Using cache
---> 0ff9ca0665b9
Step 4/8 : WORKDIR /Ampersand/ # build from the Ampersand source code directory
---> Using cache
---> a66b539a6868
Step 5/8 : RUN git clone https://github.com/AmpersandTarski/Ampersand/ .
---> Using cache
---> 1806c9a40c82
Step 6/8 : RUN git checkout feature/rio-phase2 # get Ampersand sources in the correct version
---> Using cache
---> 456074437186
Step 7/8 : RUN stack setup # set up Haskell stack (version taken from stack.yaml)
---> Using cache
---> fcadefd6812c
Step 8/8 : RUN stack install # installs Ampersand executables in /root/.local/bin
---> Running in 0a8d298a757c
Updating package index Hackage (mirrored at https://s3.amazonaws.com/hackage.fpcomplete.com/) ...
Selected mirror https://s3.amazonaws.com/hackage.fpcomplete.com/
Downloading root
Selected mirror https://s3.amazonaws.com/hackage.fpcomplete.com/
Downloading timestamp
Downloading snapshot
Downloading mirrors
Cannot update index (no local copy)
Downloading index
Updated package index downloaded
Update complete
Populating index cache ...
Populated index cache.
[1 of 2] Compiling Main ( /root/.stack/setup-exe-src/setup-mPHDZzAJ.hs, /root/.stack/setup-exe-src/setup-mPHDZzAJ.o )
[2 of 2] Compiling StackSetupShim ( /root/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs, /root/.stack/setup-exe-src/setup-shim-mPHDZzAJ.o )
Linking /root/.stack/setup-exe-cache/x86_64-linux/tmp-Cabal-simple_mPHDZzAJ_2.4.0.1_ghc-8.6.4 ...
Cabal-2.4.1.0: download
StateVar-1.1.1.1: download
HsYAML-0.1.1.3: download
StateVar-1.1.1.1: configure
SHA-1.6.4.4: download
StateVar-1.1.1.1: build
HsYAML-0.1.1.3: configure
HsYAML-0.1.1.3: build
Cabal-2.4.1.0: configure
StateVar-1.1.1.1: copy/register
<... skipping 55 lines ...>
cereal-0.5.8.0: download
cereal-0.5.8.0: configure
cereal-0.5.8.0: build
basement-0.0.10: copy/register
cereal-0.5.8.0: copy/register
blaze-html-0.9.1.1: copy/register
-- While building package Cabal-2.4.1.0 using:
/root/.stack/setup-exe-cache/x86_64-linux/Cabal-simple_mPHDZzAJ_2.4.0.1_ghc-8.6.4 --builddir=.stack-work/dist/x86_64-linux/Cabal-2.4.0.1 build --ghc-options " -ddump-hi -ddump-to-file"
Process exited with code: ExitFailure (-9) (THIS MAY INDICATE OUT OF MEMORY)
Logs have been written to: /Ampersand/ # build from the Ampersand source code directory/.stack-work/logs/Cabal-2.4.1.0.log
Configuring Cabal-2.4.1.0...
Preprocessing library for Cabal-2.4.1.0..
Building library for Cabal-2.4.1.0..
[ 1 of 220] Compiling Distribution.Compat.Binary ( Distribution/Compat/Binary.hs, .stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/Distribution/Compat/Binary.o )
[ 2 of 220] Compiling Distribution.Compat.Directory ( Distribution/Compat/Directory.hs, .stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/Distribution/Compat/Directory.o )
[ 3 of 220] Compiling Distribution.Compat.Exception ( Distribution/Compat/Exception.hs, .stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/Distribution/Compat/Exception.o )
[ 4 of 220] Compiling Distribution.Compat.Internal.TempFile ( Distribution/Compat/Internal/TempFile.hs, .stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/Distribution/Compat/Internal/TempFile.o )
[ 5 of 220] Compiling Distribution.Compat.MonadFail ( Distribution/Compat/MonadFail.hs, .stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/Distribution/Compat/MonadFail.o )
[ 6 of 220] Compiling Distribution.Compat.Newtype ( Distribution/Compat/Newtype.hs, .stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/Distribution/Compat/Newtype.o )
<... skipping 56 lines ...>
[ 63 of 220] Compiling Distribution.System ( Distribution/System.hs, .stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/Distribution/System.o )
[ 64 of 220] Compiling Distribution.SPDX.LicenseReference ( Distribution/SPDX/LicenseReference.hs, .stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/Distribution/SPDX/LicenseReference.o )
[ 65 of 220] Compiling Distribution.SPDX.LicenseId ( Distribution/SPDX/LicenseId.hs, .stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/Distribution/SPDX/LicenseId.o )
The command '/bin/sh -c stack install # installs Ampersand executables in /root/.local/bin' returned a non-zero code: 1
BA92-C02VP224HTDF:Ampersand stefjoosten$ docker start `docker ps -q -l` # restart it in the background
0a8d298a757c
BA92-C02VP224HTDF:Ampersand stefjoosten$ docker attach `docker ps -q -l`
cmark-gfm-0.1.8: build
clock-0.7.2: copy/register
colour-2.3.4: download
colour-2.3.4: configure
colour-2.3.4: build
<... skipping 200 lines ...>
primitive-0.6.4.0: copy/register
reflection-2.1.4: copy/register
hxt-9.3.1.16: copy/register
-- While building package Cabal-2.4.1.0 using:
/root/.stack/setup-exe-cache/x86_64-linux/Cabal-simple_mPHDZzAJ_2.4.0.1_ghc-8.6.4 --builddir=.stack-work/dist/x86_64-linux/Cabal-2.4.0.1 build --ghc-options " -ddump-hi -ddump-to-file"
Process exited with code: ExitFailure (-9) (THIS MAY INDICATE OUT OF MEMORY)
Logs have been written to: /Ampersand/ # build from the Ampersand source code directory/.stack-work/logs/Cabal-2.4.1.0.log
Configuring Cabal-2.4.1.0...
Preprocessing library for Cabal-2.4.1.0..
Building library for Cabal-2.4.1.0..
[ 1 of 220] Compiling Distribution.Compat.Binary ( Distribution/Compat/Binary.hs, .stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/Distribution/Compat/Binary.o )
[ 2 of 220] Compiling Distribution.Compat.Directory ( Distribution/Compat/Directory.hs, .stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/Distribution/Compat/Directory.o )
[ 3 of 220] Compiling Distribution.Compat.Exception ( Distribution/Compat/Exception.hs, .stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/Distribution/Compat/Exception.o )
[ 4 of 220] Compiling Distribution.Compat.Internal.TempFile ( Distribution/Compat/Internal/TempFile.hs, .stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/Distribution/Compat/Internal/TempFile.o )
[ 5 of 220] Compiling Distribution.Compat.MonadFail ( Distribution/Compat/MonadFail.hs, .stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/Distribution/Compat/MonadFail.o )
[ 6 of 220] Compiling Distribution.Compat.Newtype ( Distribution/Compat/Newtype.hs, .stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/Distribution/Compat/Newtype.o )
<... skipping 104 lines ...>
[111 of 220] Compiling Distribution.Types.AbiDependency ( Distribution/Types/AbiDependency.hs, .stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/Distribution/Types/AbiDependency.o )
[112 of 220] Compiling Distribution.Simple.InstallDirs ( Distribution/Simple/InstallDirs.hs, .stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/Distribution/Simple/InstallDirs.o )
[113 of 220] Compiling Distribution.Types.LegacyExeDependency ( Distribution/Types/LegacyExeDependency.hs, .stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/Distribution/Types/LegacyExeDependency.o )
[114 of 220] Compiling Distribution.Types.BuildInfo ( Distribution/Types/BuildInfo.hs, .stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/Distribution/Types/BuildInfo.o )
BA92-C02VP224HTDF:Ampersand stefjoosten$ docker start `docker ps -q -l` # restart it in the background
0a8d298a757c
BA92-C02VP224HTDF:Ampersand stefjoosten$ docker attach `docker ps -q -l`
regex-base-0.93.2: copy/register
regex-pcre-builtin-0.94.4.8.8.35: download
<... skipping 678 lines with three more interruptions ...>
pandoc-2.5: copy/register
pandoc-crossref-0.3.4.0: download
pandoc-crossref-0.3.4.0: configure
pandoc-crossref-0.3.4.0: build
pandoc-crossref-0.3.4.0: copy/register
Building all executables for `ampersand' once. After a successful build of all of them, only specified executables will be rebuilt.
ampersand-3.17.0: configure (lib + exe)
[1 of 2] Compiling Main ( /Ampersand/ # build from the Ampersand source code directory/Setup.hs, /Ampersand/ # build from the Ampersand source code directory/.stack-work/dist/x86_64-linux/Cabal-2.4.0.1/setup/Main.o )
[2 of 2] Compiling StackSetupShim ( /root/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs, /Ampersand/ # build from the Ampersand source code directory/.stack-work/dist/x86_64-linux/Cabal-2.4.0.1/setup/StackSetupShim.o )
Linking /Ampersand/ # build from the Ampersand source code directory/.stack-work/dist/x86_64-linux/Cabal-2.4.0.1/setup/setup ...
Configuring ampersand-3.17.0...
ampersand-3.17.0: build (lib + exe)
Warning: Cannot read previously generated src/Ampersand/Prototype/StaticFiles_Generated.hs:
src/Ampersand/Prototype/StaticFiles_Generated.hs: openFile: does not exist (No such file or directory)
This warning should disappear the next time you build Ampersand. If the error persists, please report this as a bug.
Static files have changed, updating src/Ampersand/Prototype/StaticFiles_Generated.hs
Preprocessing library for ampersand-3.17.0..
Building library for ampersand-3.17.0..
[ 1 of 113] Compiling Ampersand.Basics.Prelude ( src/Ampersand/Basics/Prelude.hs, .stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/Ampersand/Basics/Prelude.o )
[ 2 of 113] Compiling Ampersand.Basics.Languages ( src/Ampersand/Basics/Languages.hs, .stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/Ampersand/Basics/Languages.o )
[ 3 of 113] Compiling Ampersand.Basics.Exit ( src/Ampersand/Basics/Exit.hs, .stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/Ampersand/Basics/Exit.o )
[ 4 of 113] Compiling Ampersand.Basics.BuildInfo_Generated ( src/Ampersand/Basics/BuildInfo_Generated.hs, .stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/Ampersand/Basics/BuildInfo_Generated.o )
[ 5 of 113] Compiling Ampersand.Basics.Auxiliaries ( src/Ampersand/Basics/Auxiliaries.hs, .stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/Ampersand/Basics/Auxiliaries.o )
[ 6 of 113] Compiling Ampersand.Basics.String ( src/Ampersand/Basics/String.hs, .stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/Ampersand/Basics/String.o )
<... skipping 103 lines ...>
[110 of 113] Compiling Ampersand.Test ( src/Ampersand/Test.hs, .stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/Ampersand/Test.o )
[111 of 113] Compiling Ampersand ( src/Ampersand.hs, .stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/Ampersand.o )
[112 of 113] Compiling MainApps ( src/MainApps.hs, .stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/MainApps.o )
[113 of 113] Compiling Paths_ampersand ( .stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/autogen/Paths_ampersand.hs, .stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/Paths_ampersand.o )
Preprocessing executable 'ampersand' for ampersand-3.17.0..
Building executable 'ampersand' for ampersand-3.17.0..
[1 of 2] Compiling Main ( app/Ampersand/Main.hs, .stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/ampersand/ampersand-tmp/Main.o )
[2 of 2] Compiling Paths_ampersand ( .stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/ampersand/autogen/Paths_ampersand.hs, .stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/ampersand/ampersand-tmp/Paths_ampersand.o )
Linking .stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/ampersand/ampersand ...
ampersand-3.17.0: copy/register
Installing library in /Ampersand/ # build from the Ampersand source code directory/.stack-work/install/x86_64-linux/lts-13.16/8.6.4/lib/x86_64-linux-ghc-8.6.4/ampersand-3.17.0-K72VvTMgyU7EFfE6avLPOe
Installing executable ampersand in /Ampersand/ # build from the Ampersand source code directory/.stack-work/install/x86_64-linux/lts-13.16/8.6.4/bin
Registering library for ampersand-3.17.0..
Completed 25 action(s).
Copying from /Ampersand/ # build from the Ampersand source code directory/.stack-work/install/x86_64-linux/lts-13.16/8.6.4/bin/ampersand to /root/.local/bin/ampersand
Copied executables to /root/.local/bin:
- ampersand
但这并没有明显的区别。
如果有任何想法,我将不胜感激...
答案 0 :(得分:0)
您最好的选择可能是将--jobs 1
传递给stack
。这将关闭并发构建,这将减少内存需求。 GHC通常是一种内存消耗,特别是某些代码确实会占用大量内存进行编译。可能正在发生的事情是,两个同时占用大量内存的模块最终将在同一时间构建,而当发生这种情况时,您将最终获得OOM。但是每次运行构建时,都会构建更多软件包,并且构建顺序可以更改,因此最终您会碰运气,并且内存猪不会最终并发构建,因此构建可以完成。