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

Appmetrics doesn't work on alpine linux #438

Closed
apenney opened this issue Apr 25, 2017 · 7 comments
Closed

Appmetrics doesn't work on alpine linux #438

apenney opened this issue Apr 25, 2017 · 7 comments

Comments

@apenney
Copy link

apenney commented Apr 25, 2017

Because of musl instead of glibc I get:

[Tue Apr 25 20:23:09 2017] com.ibm.diagnostics.healthcenter.loader INFO: Node Application Metrics 3.0.1.201704110958 (Agent Core 3.2.1)
[Tue Apr 25 20:23:09 2017] com.ibm.diagnostics.healthcenter.loader WARNING: Failed to open library /home/app/code/node_modules/appmetrics/plugins/libhcapiplugin.so:Error loading shared library libagentcore.so: No such file or directory (needed by /home/app/code/node_modules/appmetrics/plugins/libhcapiplugin.so)

[Tue Apr 25 20:23:09 2017] com.ibm.diagnostics.healthcenter.loader WARNING: Failed to open library /home/app/code/node_modules/appmetrics/plugins/libhcapiplugin.so:Error loading shared library libagentcore.so: No such file or directory (needed by /home/app/code/node_modules/appmetrics/plugins/libhcapiplugin.so)

[Tue Apr 25 20:23:09 2017] com.ibm.diagnostics.healthcenter.loader WARNING: Failed to open library /home/app/code/node_modules/appmetrics/plugins/libhcapiplugin.so:Error loading shared library libagentcore.so: No such file or directory (needed by /home/app/code/node_modules/appmetrics/plugins/libhcapiplugin.so)

[Tue Apr 25 20:23:09 2017] com.ibm.diagnostics.healthcenter.loader WARNING: Failed to initialize monitoring API
/home/app/code/node_modules/appmetrics/appmetrics-api.js:207
    agent.localConnect(function events(topic, data) {
          ^

Error: Monitoring API is not initialized

I'm experimenting with self compiling on the node:6-alpine docker image but node-gyp fails to be able to compile with:

agentcore-3.2.1-linux-x64.tgz does not exist.
Falling back to node-gyp rebuild
gyp info it worked if it ends with ok
gyp info using node-gyp@3.4.0
gyp info using node@6.10.2 | linux | x64
gyp http GET https://nodejs.org/download/release/v6.10.2/node-v6.10.2-headers.tar.gz
gyp http 200 https://nodejs.org/download/release/v6.10.2/node-v6.10.2-headers.tar.gz
gyp http GET https://nodejs.org/download/release/v6.10.2/SHASUMS256.txt
gyp http 200 https://nodejs.org/download/release/v6.10.2/SHASUMS256.txt
gyp info spawn /usr/bin/python2
gyp info spawn args [ '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/home/app/code/node_modules/appmetrics/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/root/.node-gyp/6.10.2/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/root/.node-gyp/6.10.2',
gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=node.lib',
gyp info spawn args   '-Dmodule_root_dir=/home/app/code/node_modules/appmetrics',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.' ]
make: Entering directory '/home/app/code/node_modules/appmetrics/build'
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
  ACTION binding_gyp_appmetrics_target_Set_appmetrics_reported_version_build_level Release/obj.target/appmetrics/geni/appmetrics.cpp
infile: ./src/appmetrics.cpp
outfile: /home/app/code/node_modules/appmetrics/build/Release/obj.target/appmetrics/geni/appmetrics.cpp
Replacing '"99\.99\.99\.29991231"' with '"3.0.2.201704252040"'
  CXX(target) Release/obj.target/appmetrics/geni/appmetrics.o
In file included from Release/obj.target/appmetrics/geni/appmetrics.cpp:25:0:
../src/plugins/node/prof/watchdog.h: In function 'const char* watchdog::StartCpuProfiling(v8::Isolate*, uint64_t)':
../src/plugins/node/prof/watchdog.h:251:6: error: 'struct sigevent' has no member named '_sigev_un'
   ev._sigev_un._tid = profiler_tid;
      ^
../src/plugins/node/prof/watchdog.h:252:21: error: 'SIGEV_THREAD_ID' was not declared in this scope
   ev.sigev_notify = SIGEV_THREAD_ID;
                     ^
Release/obj.target/appmetrics/geni/appmetrics.cpp: In function 'void emitMessage(uv_async_t*, int)':
Release/obj.target/appmetrics/geni/appmetrics.cpp:396:18: warning: 'v8::TryCatch::TryCatch()' is deprecated: Use isolate version [-Wdeprecated-declarations]
         TryCatch try_catch;
                  ^
In file included from /root/.node-gyp/6.10.2/include/node/v8.h:25:0,
                 from /root/.node-gyp/6.10.2/include/node/node.h:42,
                 from Release/obj.target/appmetrics/geni/appmetrics.cpp:21:
/root/.node-gyp/6.10.2/include/node/v8.h:6772:40: note: declared here
   V8_DEPRECATED("Use isolate version", TryCatch());
                                        ^
/root/.node-gyp/6.10.2/include/node/v8config.h:333:3: note: in definition of macro 'V8_DEPRECATED'
   declarator __attribute__((deprecated(message)))
   ^
Release/obj.target/appmetrics/geni/appmetrics.cpp: In function 'v8::Local<v8::Object> getRequireCache(v8::Local<v8::Object>)':
Release/obj.target/appmetrics/geni/appmetrics.cpp:597:151: warning: 'v8::Local<v8::Value> v8::Object::CallAsFunction(v8::Local<v8::Value>, int, v8::Local<v8::Value>*)' is deprecated: Use maybe version [-Wdeprecated-declarations]
     Local<Value> m = module->Get(Nan::New<String>("require").ToLocalChecked())->ToObject()->CallAsFunction(Nan::GetCurrentContext()->Global(), 1, args);
                                                                                                                                                       ^
In file included from /root/.node-gyp/6.10.2/include/node/v8.h:25:0,
                 from /root/.node-gyp/6.10.2/include/node/node.h:42,
                 from Release/obj.target/appmetrics/geni/appmetrics.cpp:21:
/root/.node-gyp/6.10.2/include/node/v8.h:2984:30: note: declared here
                 Local<Value> CallAsFunction(Local<Value> recv, int argc,
                              ^
/root/.node-gyp/6.10.2/include/node/v8config.h:333:3: note: in definition of macro 'V8_DEPRECATED'
   declarator __attribute__((deprecated(message)))
   ^
Makefile:282: recipe for target 'Release/obj.target/appmetrics/geni/appmetrics.o' failed
make: *** [Release/obj.target/appmetrics/geni/appmetrics.o] Error 1
make: Leaving directory '/home/app/code/node_modules/appmetrics/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Linux 4.9.21-moby
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/app/code/node_modules/appmetrics
gyp ERR! node -v v6.10.2
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
npm info lifecycle appmetrics@3.0.2~install: Failed to exec install script
npm ERR! Linux 4.9.21-moby
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "appmetrics"
npm ERR! node v6.10.2
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE

npm ERR! appmetrics@3.0.2 install: `node extract_all_binaries.js || node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the appmetrics@3.0.2 install script 'node extract_all_binaries.js || node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the appmetrics package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node extract_all_binaries.js || node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs appmetrics
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls appmetrics
npm ERR! There is likely additional logging output above.
@si-harps
Copy link

si-harps commented May 12, 2017

Also having this issue running alpine-node:6.4.0

Creating efeuserinterface_app_1
Attaching to efeuserinterface_app_1
app_1 |
app_1 | > efe-user-interface@1.0.11 start /app
app_1 | > node server.js
app_1 |
app_1 | [Fri May 12 14:42:27 2017] com.ibm.diagnostics.healthcenter.loader INFO: Node Application Metrics 3.0.1.201704110958 (Agent Core 3.2.1)
app_1 | [Fri May 12 14:42:27 2017] com.ibm.diagnostics.healthcenter.loader WARNING: Failed to open library /app/node_modules/appmetrics/plugins/libhcapiplugin.so:Error loading shared library libagentcore.so: No such file or directory (needed by /app/node_modules/appmetrics/plugins/libhcapiplugin.so)
app_1 |
app_1 | [Fri May 12 14:42:27 2017] com.ibm.diagnostics.healthcenter.loader WARNING: Failed to open library /app/node_modules/appmetrics/plugins/libhcapiplugin.so:Error loading shared library libagentcore.so: No such file or directory (needed by /app/node_modules/appmetrics/plugins/libhcapiplugin.so)
app_1 |
app_1 | [Fri May 12 14:42:27 2017] com.ibm.diagnostics.healthcenter.loader WARNING: Failed to open library /app/node_modules/appmetrics/plugins/libhcapiplugin.so:Error loading shared library libagentcore.so: No such file or directory (needed by /app/node_modules/appmetrics/plugins/libhcapiplugin.so)
app_1 |
app_1 | [Fri May 12 14:42:27 2017] com.ibm.diagnostics.healthcenter.loader WARNING: Failed to initialize monitoring API

@noxxious
Copy link

noxxious commented Sep 19, 2017

I've run into this issue also and had to do couple of workarounds:

  • install libc-compat
  • set LD_LIBRARY_PATH=/app/node_modules/appmetrics explicitely

This is the ending Dockerfile:

FROM node:8-alpine as build

ENV YARN_VERSION 1.0.2

RUN apk add --no-cache --virtual build-dependencies --update \
    curl \
    python \
    build-base \
    libexecinfo-dev

RUN set -ex \
    && curl -o- -L https://yarnpkg.com/install.sh | sh -s -- --version $YARN_VERSION \

ARG PATH=/root/.yarn/bin:$PATH
ENV PATH /root/.yarn/bin:$PATH
ENV NODE_ENV production
ENV DOCKER_BUILD=true

COPY . /app/
WORKDIR /app

RUN yarn install

# Cleanup
RUN apk del build-dependencies

FROM node:8-alpine

RUN apk add --no-cache --virtual run-dependencies --update \
    libc6-compat

COPY --from=build /root/.yarn /root/.yarn
COPY --from=build /app /app
WORKDIR /app

ENV PATH /root/.yarn/bin:$PATH
ENV START_COMMAND start
ENV PORT 8040
ENV NODE_ENV production
ENV LD_LIBRARY_PATH /app/node_modules/appmetrics
EXPOSE 8040

CMD npm start

@tobespc
Copy link
Member

tobespc commented Sep 20, 2017

@noxxious Thanks for the info, use containers to deploy appmetrics is something we are looking at right now so this is very useful

@sjanuary
Copy link
Contributor

Duplicate of #454

@sjanuary sjanuary marked this as a duplicate of #454 Oct 16, 2017
@Nagasai-Aytha
Copy link

@noxxious , could you please details of package - libc-compat, because I am unable to find that pakage

@abubeck
Copy link

abubeck commented Feb 9, 2018

@Nagasai-Aytha: It is called libc6-compat.

@tiberiuzuld
Copy link

Adding libc6-compat and ENV LD_LIBRARY_PATH /usr/app/node_modules/appmetrics made it work for me.

DanailMinchev added a commit to alphagov/pay-direct-debit-frontend that referenced this issue May 3, 2018
- Upgrade Node.js to latest LTS version `8.11.1` and use `govukpay/nodejs:8.11.1` image
- Specify the new version in `.nvmrc` and `package.json`
- Use `package-lock.json` instead of `npm-shrinkwrap.json`
- Upgrade `appmetrics` library and initialisation (see RuntimeTools/appmetrics#438 (comment))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants