Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions api/ecosystem.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"max_restarts": 10,
"min_uptime": 10000,
"watch": false,
"interpreter": "/usr/local/node/bin/node",
"ignore_watch": ["node_modules", "src", ".env.*", "myservers.cfg"],
"log_file": "/var/log/graphql-api.log",
"kill_timeout": 10000
Expand Down
2 changes: 0 additions & 2 deletions api/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env node

import '@app/dotenv.js';

import { execa } from 'execa';
Expand Down
28 changes: 21 additions & 7 deletions api/src/environment.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
import { readFileSync } from 'node:fs';
import { homedir } from 'node:os';
import { dirname, join } from 'node:path';
import { join } from 'node:path';
import { fileURLToPath } from 'node:url';

const getPackageJsonVersion = () => {
try {
// Use import.meta.resolve to get the URL of package.json
const packageJsonUrl = import.meta.resolve('../package.json');
const packageJsonPath = fileURLToPath(packageJsonUrl);
const packageJson = readFileSync(packageJsonPath, 'utf-8');
const packageJsonObject = JSON.parse(packageJson);
return packageJsonObject.version;
// Try different possible locations for package.json
const possibleLocations = ['../package.json', '../../package.json'];

for (const location of possibleLocations) {
try {
const packageJsonUrl = import.meta.resolve(location);
const packageJsonPath = fileURLToPath(packageJsonUrl);
const packageJson = readFileSync(packageJsonPath, 'utf-8');
const packageJsonObject = JSON.parse(packageJson);
if (packageJsonObject.version) {
return packageJsonObject.version;
}
} catch {
// Continue to next location if this one fails
}
}

// If we get here, we couldn't find a valid package.json in any location
console.error('Could not find package.json in any of the expected locations');
return undefined;
} catch (error) {
console.error('Failed to load package.json:', error);
return undefined;
Expand Down
6 changes: 6 additions & 0 deletions api/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ export default defineConfig(({ mode }): ViteUserConfig => {
entryFileNames: '[name].js',
format: 'es',
interop: 'auto',
banner: (chunk) => {
if (chunk.fileName === 'main.js' || chunk.fileName === 'cli.js') {
return '#!/usr/local/node/bin/node\n';
}
return '';
},
},
preserveEntrySignatures: 'strict',
external: [
Expand Down
2 changes: 2 additions & 0 deletions plugin/plugins/dynamix.unraid.net.plg
Original file line number Diff line number Diff line change
Expand Up @@ -907,9 +907,11 @@ fi


# Create symlink to unraid-api binary (to allow usage elsewhere)
ln -sf /usr/local/node/bin/node /usr/local/bin/node
ln -sf ${unraid_binary_path} /usr/local/sbin/unraid-api
ln -sf ${unraid_binary_path} /usr/bin/unraid-api


logger "Starting flash backup (if enabled)"
echo "/etc/rc.d/rc.flash_backup start" | at -M now &>/dev/null
. /root/.bashrc
Expand Down
6 changes: 0 additions & 6 deletions plugin/source/dynamix.unraid.net/etc/profile.d/node.sh

This file was deleted.

Loading