Skip to content

Commit

Permalink
Add more logging to cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
zombiezen committed Nov 12, 2023
1 parent 162f1a8 commit 19f50a9
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ jobs:
secret_keys: ${{ secrets.NIX_PRIVATE_KEY }}
use_nixcached: true
- name: nix build
run: nix build '.#nodejs'
run: nix build '.#devShells.x86_64-linux.default'
10 changes: 5 additions & 5 deletions dist/cleanup.js

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions dist/index.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions src/cleanup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
SYSTEMD_DROPIN_STATE,
SERVICES_STATE,
runCommand,
UPLOAD_SERVICE_UNIT,
} from './common';

(async () => {
Expand All @@ -36,6 +37,13 @@ import {
servicesStarted instanceof Array &&
servicesStarted.every((x) => typeof x === 'string')
) {
if (servicesStarted.indexOf(UPLOAD_SERVICE_UNIT) >= 0) {
await runCommand([
'journalctl',
`--user-unit=${UPLOAD_SERVICE_UNIT}`,
]);
}
info(`Stopping systemd services ${servicesStarted.join()}...`);
await runCommand(['systemctl', 'stop', '--user', ...servicesStarted]);
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export const TEMP_DIR_STATE = 'tempdir';
export const SYSTEMD_DROPIN_STATE = 'systemd';
export const SERVICES_STATE = 'systemd_services';

export const UPLOAD_SERVICE_UNIT = 'nixcached-upload.service';

export interface RootCommandOptions {
ignoreStderr?: boolean;
}
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
SERVICES_STATE,
SYSTEMD_DROPIN_STATE,
TEMP_DIR_STATE,
UPLOAD_SERVICE_UNIT,
} from './common';
import { generate } from './config_gen';

Expand Down Expand Up @@ -194,12 +195,11 @@ const NIXCACHED_PORT = 38380;

if (nixcachedPipe) {
debug('Starting nixcached upload...');
const UPLOAD_SERVICE = 'nixcached-upload.service';
servicesStarted.push(UPLOAD_SERVICE);
servicesStarted.push(UPLOAD_SERVICE_UNIT);
await runCommand([
'systemd-run',
'--user',
`--unit=${UPLOAD_SERVICE}`,
`--unit=${UPLOAD_SERVICE_UNIT}`,
'--property=KillMode=mixed',
'--property=KillSignal=SIGHUP',
...setenvFlags,
Expand Down

0 comments on commit 19f50a9

Please sign in to comment.