Skip to content

Commit

Permalink
fix: solve memory issues during install w/ npm v7
Browse files Browse the repository at this point in the history
The dependency tree was slimmed down to avoid running into memory issues
during installations with npm v7. Notably, the logger dependencies were
moved to be optional peer dependencies. Most users won't use these and
don't need the whole tree to be installed, the rest can easily provide
them with a separate install.

Closes #514
  • Loading branch information
mKeRix committed Apr 11, 2021
1 parent 3eae74a commit 53525db
Show file tree
Hide file tree
Showing 8 changed files with 244 additions and 1,120 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Expand Up @@ -13,6 +13,7 @@ RUN apk add --no-cache bluez bluez-deprecated libusb avahi-dev bind-tools dmidec
&& setcap cap_net_raw+eip $(eval readlink -f `which hcitool`) \
&& setcap cap_net_admin+eip $(eval readlink -f `which hciconfig`) \
&& ln -s /usr/local/lib/node_modules/room-assistant/bin/room-assistant.js /usr/local/bin/room-assistant
RUN npm install -g winston-loki winston-elasticsearch
COPY --from=build /usr/local/lib/node_modules/room-assistant /usr/local/lib/node_modules/room-assistant

ENTRYPOINT ["tini", "--", "room-assistant"]
Expand Down
19 changes: 0 additions & 19 deletions bin/room-assistant.js
Expand Up @@ -2,28 +2,9 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const pkg = require('../package.json');
require('please-upgrade-node')(pkg);
const updateNotifier = require('update-notifier');
const chalk = require('chalk');
const commandLineUsage = require('command-line-usage');
const commandLineArgs = require('command-line-args');

const isBeta = pkg.version.includes('beta');
let updateCommand = 'npm i -g --unsafe-perm {packageName}';
if (isBeta) {
updateCommand += '@beta';
}

updateNotifier({
pkg,
distTag: isBeta ? 'beta' : 'latest',
}).notify({
message: `Update available ${chalk.dim('{currentVersion}')} ${chalk.reset(
'→'
)} ${chalk.green('{latestVersion}')} \nRun ${chalk.cyan(
updateCommand
)} to update`,
});

const optionDefinitions = [
{
name: 'help',
Expand Down
1 change: 1 addition & 0 deletions dev.Dockerfile
Expand Up @@ -14,6 +14,7 @@ RUN apk add --no-cache bluez bluez-deprecated libusb avahi-dev bind-tools dmidec
&& setcap cap_net_raw+eip $(eval readlink -f `which hcitool`) \
&& setcap cap_net_admin+eip $(eval readlink -f `which hciconfig`) \
&& ln -s /usr/local/lib/node_modules/room-assistant/bin/room-assistant.js /usr/local/bin/room-assistant
RUN npm install -g winston-loki winston-elasticsearch
COPY --from=build /usr/local/lib/node_modules/room-assistant /usr/local/lib/node_modules/room-assistant

ENTRYPOINT ["tini", "--", "room-assistant"]
Expand Down
4 changes: 2 additions & 2 deletions docs/guide/monitoring.md
Expand Up @@ -27,7 +27,7 @@ If you want to capture the logs of all your instances in a single place you can

**Config Key:** `elasticsearch`

room-assistant is capable of piping log output into an Elasticsearch cluster with the logstash format, which makes it searchable from Kibana.
room-assistant is capable of piping log output into an Elasticsearch cluster with the logstash format, which makes it searchable from Kibana. On NodeJS installations this logger requires an additional dependency, which you can install with `npm install -g winston-elasticsearch`.

| Name | Type | Default | Description |
| ------------- | ------- | --------------------- | ------------------------------------------------------------ |
Expand All @@ -51,7 +51,7 @@ logger:

**Config Key:** `loki`

You can send the room-assistant logs to an instance of [Grafana Loki](https://grafana.com/oss/loki/), which will allow you to collect and query logs easily from [Grafana](https://grafana.com/grafana/).
You can send the room-assistant logs to an instance of [Grafana Loki](https://grafana.com/oss/loki/), which will allow you to collect and query logs easily from [Grafana](https://grafana.com/grafana/). On NodeJS installations this logger requires an additional dependency, which you can install with `npm install -g winston-loki`.

| Name | Type | Default | Description |
| --------- | ------- | --------------------- | ------------------------------------------------------- |
Expand Down

0 comments on commit 53525db

Please sign in to comment.