diff --git a/Dockerfile b/Dockerfile index 13b0fd15e8ea7ca09740c659da483134b8cb9c73..08f36bf16024941ff8a7e832189e1174a8323e03 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,6 +21,7 @@ COPY .gitignore_recorder deadlock/.gitignore COPY setup_trace.py . RUN chmod 700 setup_trace.py RUN chown theia setup_trace.py + COPY start.sh . RUN chmod 504 deadlock/ -R RUN chmod 500 start.sh diff --git a/plugins/deadlock-extension/src/recorder/command-recorder.ts b/plugins/deadlock-extension/src/recorder/command-recorder.ts index 38cbe87ab1e1e108e08dbdc747f5138eb2fa0491..ca941693d5f0ec9953d36082d96fda2fb3641beb 100644 --- a/plugins/deadlock-extension/src/recorder/command-recorder.ts +++ b/plugins/deadlock-extension/src/recorder/command-recorder.ts @@ -1,23 +1,8 @@ import GitMission from '../core/gitMission'; import { error, commitAndPushCode, CommitFrom, log } from './utils'; const async = require('async'); - -// regex to match command line in ps aux -/** - * group 0: Full match - * group 1: USER (theia) - * group 2: PID - * group 3: START - * group 4: TIME - * group 5: Command - */ - -const child = require('child_process'); const fs = require('fs'); -const regexPsCommand = - /(theia).+?([\d]+).+?([\d]+\:[\d]+).+?([\d+]\:[\d+]+) (.+)/; - class Command { public still: boolean; @@ -64,9 +49,11 @@ export default class CommandRecorder { let lastLineIndexWatched = 0; setInterval(() => { try { - const trace = fs.readFileSync('/tmp/.trace', 'utf8'); + const trace = fs.readFileSync('/home/theia/.bash_history', 'utf8'); const lines = trace.split(/\r?\n/); + this.commandsInProgress.forEach((command) => (command.still = false)); + for (let index = lastLineIndexWatched; index < lines.length; index++) { const line = lines[index]; if ( @@ -76,11 +63,10 @@ export default class CommandRecorder { line.indexOf('npm run') !== -1 || line.indexOf('npm start') !== -1 ) { - log('smth executed'); this.somethingExecuted(index, line); } } - lastLineIndexWatched = lines.length; + lastLineIndexWatched = lines.length - 1; // clear command down (means still = false) this.commandsInProgress.forEach((command) => { @@ -91,6 +77,6 @@ export default class CommandRecorder { } catch (e) { console.error(e); } - }, 500); + }, 1300); } } diff --git a/plugins/deadlock-extension/src/view/briefingView.ts b/plugins/deadlock-extension/src/view/briefingView.ts index 755c8901f696b6bf5132a2cea469bc4db088cbfb..589323eb731258efab4e206cfddeed28048466f7 100644 --- a/plugins/deadlock-extension/src/view/briefingView.ts +++ b/plugins/deadlock-extension/src/view/briefingView.ts @@ -27,11 +27,10 @@ export default class BriefingView extends WebviewBase { } toBase64(file: string) { - const re = fs.readFileSync(path.join(DOCS_PATH, file), { + const result = fs.readFileSync(path.join(DOCS_PATH, file), { encoding: "base64", }); - console.log("re", re); - return re; + return result; } setupImages(text: string) { diff --git a/setup_trace.py b/setup_trace.py index 7628606456d9a18d2796961bf8d30a8217d02050..313589500a92f3dd57d6be106950d9382fe7a730 100644 --- a/setup_trace.py +++ b/setup_trace.py @@ -1,12 +1,11 @@ -open('/tmp/.trace', 'a').close() +open('/home/theia/.bash_history', 'a').close() bashrc = open('/home/theia/.bashrc', 'a') bashrc.write('\n') -bashrc.write('''PS4=\'$(echo $(date) $(history 1) >> /tmp/.trace)\'''') - +bashrc.write('HISTCONTROL=""') bashrc.write('\n') -bashrc.write('export PS4') +bashrc.write("PROMPT_COMMAND='history -a'") bashrc.write('\n') # Close the file diff --git a/start.sh b/start.sh index 46017bd71e1bbdb16fca73b4075bd58edaf53634..4784e528d8b32fac12454afd75e6bc092e6fa83a 100755 --- a/start.sh +++ b/start.sh @@ -8,14 +8,10 @@ cp /tmp/.ssh/* ~/.ssh/ # start command recorder node deadlock/recorder.js & - -#trap 'if [[ "$BASH_COMMAND" == "java "* ]]; then printf "[%s]\n" ${BASH_COMMAND#echo}; false; fi' DEBUG -#set -T -#shopt -s extdebug - deluser theia sudo su theia --command "python setup_trace.py" +rm setup_trace.py # starting theia as THEIA su theia --command "node /home/theia/src-gen/backend/main.js /home/project --hostname=0.0.0.0 --plugins=local-dir:/home/plugins" \ No newline at end of file