@@ -5,25 +5,36 @@ import '@app/dotenv';
55import { execa } from 'execa' ;
66import { CommandFactory } from 'nest-commander' ;
77
8- import { cliLogger , internalLogger } from '@app/core/log' ;
8+ import { internalLogger , logger } from '@app/core/log' ;
9+ import { LOG_LEVEL } from '@app/environment' ;
910import { CliModule } from '@app/unraid-api/cli/cli.module' ;
11+ import { LogService } from '@app/unraid-api/cli/log.service' ;
12+
13+ const getUnraidApiLocation = async ( ) => {
14+ try {
15+ const shellToUse = await execa ( 'which unraid-api' ) ;
16+ if ( shellToUse . code !== 0 ) {
17+ throw new Error ( 'unraid-api not found' ) ;
18+ }
19+ return shellToUse . stdout . trim ( ) ;
20+ } finally {
21+ return '/usr/bin/unraid-api' ;
22+ }
23+ } ;
1024
1125try {
12- const shellToUse = await execa ( 'which unraid-api' )
13- . then ( ( res ) => res . toString ( ) . trim ( ) )
14- . catch ( ( _ ) => '/usr/local/bin/unraid-api' ) ;
1526 await CommandFactory . run ( CliModule , {
1627 cliName : 'unraid-api' ,
17- logger : false , // new LogService(), - enable this to see nest initialization issues
28+ logger : LOG_LEVEL === 'TRACE' && new LogService ( ) , // - enable this to see nest initialization issues
1829 completion : {
19- fig : true ,
30+ fig : false ,
2031 cmd : 'completion-script' ,
21- nativeShell : { executablePath : shellToUse } ,
32+ nativeShell : { executablePath : await getUnraidApiLocation ( ) } ,
2233 } ,
2334 } ) ;
2435 process . exit ( 0 ) ;
2536} catch ( error ) {
26- cliLogger . error ( 'ERROR:' , error ) ;
37+ logger . error ( 'ERROR:' , error ) ;
2738 internalLogger . error ( {
2839 message : 'Failed to start unraid-api' ,
2940 error,
0 commit comments