Skip to content

Commit

Permalink
feat: handle docker file sharing permissions on start-up (#830)
Browse files Browse the repository at this point in the history
Signed-off-by: nikolay <[email protected]>
  • Loading branch information
natanasow authored Nov 8, 2024
1 parent f5f8f67 commit ea6fc5b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,6 @@ export const ACCOUNT_CREATION_FINISHED = `${CHECK_SUCCESS} Accounts created succ
export const RESOURCE_CREATION_STATE_INIT_MESSAGE = `${CHECK_SUCCESS} Resource Creation State Initialized!`;
export const RESOURCE_CREATION_STARTING_SYNCHRONOUS_MESSAGE = `${LOADING} Starting Resource Creation state in synchronous mode...`;
export const RESOURCE_CREATION_STARTING_ASYNCHRONOUS_MESSAGE = `${LOADING} Starting Resource Creation state in asynchronous mode...`;

// Docker messages
export const SHARED_PATHS_ERROR = `You can configure shared paths from Docker -> Preferences... -> Resources -> File Sharing.`;
18 changes: 12 additions & 6 deletions src/services/DockerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ import Dockerode from 'dockerode';
import shell from 'shelljs';
import semver from'semver';
import fs from 'fs';
import { IS_WINDOWS, NECESSARY_PORTS, UNKNOWN_VERSION, OPTIONAL_PORTS,
MIN_CPUS, MIN_MEMORY_MULTI_MODE, MIN_MEMORY_SINGLE_MODE,
RECOMMENDED_CPUS, RECOMMENDED_MEMORY_SINGLE_MODE,
CHECK_SUCCESS,
CHECK_FAIL,
LOADING} from '../constants';
import {
IS_WINDOWS, NECESSARY_PORTS, UNKNOWN_VERSION, OPTIONAL_PORTS, MIN_CPUS,
MIN_MEMORY_MULTI_MODE, MIN_MEMORY_SINGLE_MODE, RECOMMENDED_CPUS,
RECOMMENDED_MEMORY_SINGLE_MODE, CHECK_SUCCESS, CHECK_FAIL, LOADING,
SHARED_PATHS_ERROR
} from '../constants';
import { IService } from './IService';
import { LoggerService } from './LoggerService';
import { ServiceLocator } from './ServiceLocator';
Expand Down Expand Up @@ -260,6 +260,12 @@ export class DockerService implements IService{
private logShellOutput(shellExec: any) {
[shellExec.stdout, shellExec.stderr].forEach( (output: string) => {
output.split("\n").map((line: string) => {
if (line.indexOf(SHARED_PATHS_ERROR) > -1) {
this.logger.error(`Hedera local node start up TERMINATED due to docker's misconfiguration`);
this.logger.error(SHARED_PATHS_ERROR);
this.logger.error(`See https://docs.docker.com/desktop/settings/mac/#file-sharing for more info.`);
process.exit();
}
if (line === "") return;
this.logger.debug(line, this.serviceName);
});
Expand Down

0 comments on commit ea6fc5b

Please sign in to comment.