-
Notifications
You must be signed in to change notification settings - Fork 19
fix(startup): defer connect and temperature boot tasks #1988
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
479d76f
fix(startup): defer connect and temperature boot tasks
elibosley 7e2739b
refactor(startup): remove zero-delay startup timers
elibosley 94bfa73
style(startup): fix prettier ordering in temperature tasks
elibosley c983f43
refactor(temperature): move app-ready startup into service
elibosley 119a822
test(temperature): update disk sensor availability spec
elibosley d454d08
test(connect): await empty startup task run
elibosley c1bfdd3
fix(cli): harden pm2 service lifecycle commands
elibosley 0729266
fix(plugin): create recovery archive during install
elibosley 6a55fe0
fix(startup): harden deferred task failures
elibosley 9c69358
fix(temperature): keep provider probes retryable
elibosley 9e977da
fix(ci): start libvirt idempotently
elibosley 608fd71
fix(ci): keep libvirt diagnostics non-blocking
elibosley cec65c3
fix(cli): restore compact PM2 output
elibosley 76bf831
fix(plugin): remove dependency archive recovery requirement
elibosley f983e2d
fix(connect): defer connect startup tasks
elibosley 6d7aa96
fix(pm2): enable discrete mode by default
elibosley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| import { describe, expect, it, vi } from 'vitest'; | ||
|
|
||
| import { ECOSYSTEM_PATH } from '@app/environment.js'; | ||
| import { LogService } from '@app/unraid-api/cli/log.service.js'; | ||
| import { PM2Service } from '@app/unraid-api/cli/pm2.service.js'; | ||
| import { RestartCommand } from '@app/unraid-api/cli/restart.command.js'; | ||
| import { StartCommand } from '@app/unraid-api/cli/start.command.js'; | ||
| import { StatusCommand } from '@app/unraid-api/cli/status.command.js'; | ||
| import { StopCommand } from '@app/unraid-api/cli/stop.command.js'; | ||
|
|
||
| const createLogger = (): LogService => | ||
| ({ | ||
| trace: vi.fn(), | ||
| warn: vi.fn(), | ||
| error: vi.fn(), | ||
| log: vi.fn(), | ||
| info: vi.fn(), | ||
| debug: vi.fn(), | ||
| }) as unknown as LogService; | ||
|
|
||
| const createPm2Service = () => | ||
| ({ | ||
| run: vi.fn().mockResolvedValue({ stdout: '', stderr: '' }), | ||
| ensurePm2Dependencies: vi.fn().mockResolvedValue(undefined), | ||
| deleteDump: vi.fn().mockResolvedValue(undefined), | ||
| deletePm2Home: vi.fn().mockResolvedValue(undefined), | ||
| forceKillPm2Daemon: vi.fn().mockResolvedValue(undefined), | ||
| }) as unknown as PM2Service; | ||
|
|
||
| describe('PM2-backed CLI commands', () => { | ||
| it('start clears PM2 state and starts with mini-list output', async () => { | ||
| const logger = createLogger(); | ||
| const pm2 = createPm2Service(); | ||
| const command = new StartCommand(logger, pm2); | ||
|
|
||
| await command.run([], { logLevel: 'info' }); | ||
|
|
||
| expect(pm2.ensurePm2Dependencies).toHaveBeenCalledTimes(1); | ||
| expect(pm2.deleteDump).toHaveBeenCalledTimes(1); | ||
| expect(pm2.deletePm2Home).toHaveBeenCalledTimes(1); | ||
| expect(pm2.run).toHaveBeenNthCalledWith(1, { tag: 'PM2 Stop' }, 'stop', ECOSYSTEM_PATH); | ||
| expect(pm2.run).toHaveBeenNthCalledWith(2, { tag: 'PM2 Update' }, 'update'); | ||
| expect(pm2.run).toHaveBeenNthCalledWith(3, { tag: 'PM2 Delete' }, 'delete', ECOSYSTEM_PATH); | ||
| expect(pm2.run).toHaveBeenNthCalledWith(4, { tag: 'PM2 Kill' }, 'kill', '--no-autorestart'); | ||
| expect(pm2.run).toHaveBeenNthCalledWith( | ||
| 5, | ||
| { tag: 'PM2 Start', raw: true, extendEnv: true, env: { LOG_LEVEL: 'info' } }, | ||
| 'start', | ||
| ECOSYSTEM_PATH, | ||
| '--update-env', | ||
| '--mini-list' | ||
| ); | ||
| }); | ||
|
|
||
| it('restart uses mini-list output for the PM2 restart call', async () => { | ||
| const logger = createLogger(); | ||
| const pm2 = createPm2Service(); | ||
| const command = new RestartCommand(logger, pm2); | ||
|
|
||
| await command.run([], { logLevel: 'info' }); | ||
|
|
||
| expect(pm2.run).toHaveBeenCalledWith( | ||
| { tag: 'PM2 Restart', raw: true, extendEnv: true, env: { LOG_LEVEL: 'info' } }, | ||
| 'restart', | ||
| ECOSYSTEM_PATH, | ||
| '--update-env', | ||
| '--mini-list' | ||
| ); | ||
| }); | ||
|
|
||
| it('status uses mini-list output for the PM2 status call', async () => { | ||
| const pm2 = createPm2Service(); | ||
| const command = new StatusCommand(pm2); | ||
|
|
||
| await command.run(); | ||
|
|
||
| expect(pm2.run).toHaveBeenCalledWith( | ||
| { tag: 'PM2 Status', stdio: 'inherit', raw: true }, | ||
| 'status', | ||
| 'unraid-api', | ||
| '--mini-list' | ||
| ); | ||
| }); | ||
|
|
||
| it('stop uses mini-list output for the PM2 delete call', async () => { | ||
| const pm2 = createPm2Service(); | ||
| const command = new StopCommand(pm2); | ||
|
|
||
| await command.run([], { delete: false }); | ||
|
|
||
| expect(pm2.run).toHaveBeenCalledWith( | ||
| { tag: 'PM2 Delete', stdio: 'inherit' }, | ||
| 'delete', | ||
| ECOSYSTEM_PATH, | ||
| '--no-autorestart', | ||
| '--mini-list' | ||
| ); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also force-kill the PM2 daemon before deleting
PM2_HOME.The hardened
stop --deletepath already doespm2 killthenforceKillPm2Daemon()thendeletePm2Home(). SkippingforceKillPm2Daemon()here means the new startup-recovery path can still race a stuck daemon and fail to clear the old state cleanly.Suggested fix
await this.pm2.run({ tag: 'PM2 Delete' }, 'delete', ECOSYSTEM_PATH); await this.pm2.run({ tag: 'PM2 Kill' }, 'kill', '--no-autorestart'); + await this.pm2.forceKillPm2Daemon(); await this.pm2.deletePm2Home();📝 Committable suggestion
🤖 Prompt for AI Agents