Skip to content

Commit 1d1c777

Browse files
committed
set service mode as default, remove standalone
1 parent ca989ae commit 1d1c777

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+67
-629
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ All notable changes to `homebridge-config-ui-x` will be documented in this file.
2424
- make terminal enabled by default on new macOS hb-service installs
2525
- update `fastify` and `nestjs` dependencies
2626
- remove `log.tail` and `log.systemd` ui settings
27+
- set service mode as default, remove standalone
2728

2829
### Homebridge Dependencies
2930

config.schema.json

Lines changed: 0 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,6 @@
176176
}
177177
]
178178
},
179-
"restart": {
180-
"title": "Custom Restart Command",
181-
"type": "string",
182-
"description": "If no restart command is set the process will terminate with a non-zero exit code.",
183-
"placeholder": "eg. sudo systemctl restart homebridge"
184-
},
185179
"temp": {
186180
"title": "OS Temp File Path",
187181
"type": "string",
@@ -398,39 +392,19 @@
398392
"type": "string",
399393
"placeholder": "eg. /home/pi/mywallpaper.jpg"
400394
},
401-
"sudo": {
402-
"title": "Use Sudo",
403-
"type": "boolean",
404-
"description": "If you are running Homebridge as root, you may need to enable this option."
405-
},
406395
"homebridgePackagePath": {
407396
"title": "Path To Homebridge Module",
408397
"type": "string",
409398
"description": "If you have multiple versions of Homebridge installed, you can specify the path to the version you want to use here.",
410399
"placeholder": "eg. /usr/local/lib/node_modules/homebridge"
411400
},
412-
"noFork": {
413-
"title": "Do not run the UI server in a separate process/thread",
414-
"type": "boolean",
415-
"description": "If you are running Homebridge in a container, you may need to enable this option."
416-
},
417401
"host": {
418402
"title": "Host IP Address",
419403
"type": "string",
420404
"pattern": "^[^{}/ :\\\\]+(?::\\d+)?$",
421405
"description": "The host IP address to listen on. In most cases this will be '::' or '0.0.0.0'.",
422406
"placeholder": "eg. 0.0.0.0"
423407
},
424-
"debug": {
425-
"title": "Enable Debug Logging",
426-
"type": "boolean",
427-
"description": "If enabled, the Homebridge UI will log debug level messages to the console."
428-
},
429-
"standalone": {
430-
"title": "Tell Homebridge the plugin is operating in standalone mode",
431-
"type": "boolean",
432-
"description": "If you are running Homebridge in a container, you may need to enable this option."
433-
},
434408
"sessionTimeout": {
435409
"title": "Session Timeout (Seconds)",
436410
"type": "integer",
@@ -447,65 +421,6 @@
447421
"title": "Log Settings",
448422
"description": "The log settings for the Homebridge UI.",
449423
"properties": {
450-
"method": {
451-
"title": "Log Method",
452-
"type": "string",
453-
"default": "",
454-
"description": "The method used to read the Homebridge log file.",
455-
"oneOf": [
456-
{
457-
"title": "Default",
458-
"enum": [
459-
""
460-
]
461-
},
462-
{
463-
"title": "From File",
464-
"enum": [
465-
"file"
466-
]
467-
},
468-
{
469-
"title": "Systemd",
470-
"enum": [
471-
"systemd"
472-
]
473-
},
474-
{
475-
"title": "Custom Command",
476-
"enum": [
477-
"custom"
478-
]
479-
}
480-
]
481-
},
482-
"path": {
483-
"title": "Log File Path",
484-
"type": "string",
485-
"description": "Enter the full file path to your log file.",
486-
"placeholder": "/var/log/homebridge.log",
487-
"condition": {
488-
"functionBody": "return (model.log && model.log.method==='file')"
489-
}
490-
},
491-
"service": {
492-
"title": "Systemd Service",
493-
"type": "string",
494-
"description": "Enter the systemd service name. Defaults to 'homebridge'.",
495-
"placeholder": "homebridge",
496-
"condition": {
497-
"functionBody": "return (model.log && model.log.method==='systemd')"
498-
}
499-
},
500-
"command": {
501-
"title": "Custom Command",
502-
"description": "This command should stream the logs to stdout.",
503-
"type": "string",
504-
"placeholder": "journalctl -f -n 100 -u homebridge",
505-
"condition": {
506-
"functionBody": "return (model.log && model.log.method==='custom')"
507-
}
508-
},
509424
"maxSize": {
510425
"type": "integer",
511426
"description": "The max log size (bytes). Set to -1 to disable log truncation.",
@@ -636,19 +551,6 @@
636551
}
637552
]
638553
},
639-
{
640-
"ref": "log",
641-
"type": "fieldset",
642-
"expandable": true,
643-
"title": "Log Settings",
644-
"items": [
645-
"debug",
646-
"log.method",
647-
"log.path",
648-
"log.service",
649-
"log.command"
650-
]
651-
},
652554
{
653555
"ref": "logRetention",
654556
"type": "fieldset",
@@ -706,8 +608,6 @@
706608
"expandable": true,
707609
"title": "Homebridge Settings",
708610
"items": [
709-
"sudo",
710-
"restart",
711611
"homebridgePackagePath"
712612
]
713613
},
@@ -728,16 +628,6 @@
728628
"linux.restart",
729629
"temp"
730630
]
731-
},
732-
{
733-
"ref": "container",
734-
"type": "fieldset",
735-
"expandable": true,
736-
"title": "Container Settings",
737-
"items": [
738-
"standalone",
739-
"noFork"
740-
]
741631
}
742632
]
743633
},

src/core/config/config.service.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ export class ConfigService {
3838

3939
// Server env
4040
public minimumNodeVersion = '20.18.0'
41-
public serviceMode = (process.env.UIX_SERVICE_MODE === '1')
4241
public runningInDocker = Boolean(process.env.HOMEBRIDGE_CONFIG_UI === '1')
4342
public runningInSynologyPackage = Boolean(process.env.HOMEBRIDGE_SYNOLOGY_PACKAGE === '1')
4443
public runningInPackageMode = Boolean(process.env.HOMEBRIDGE_APT_PACKAGE === '1')
@@ -108,12 +107,10 @@ export class ConfigService {
108107
temp?: string
109108
tempUnits?: string
110109
loginWallpaper?: string
111-
noFork?: boolean
112110
linux?: {
113111
shutdown?: string
114112
restart?: string
115113
}
116-
standalone?: boolean
117114
debug?: boolean
118115
proxyHost?: string
119116
sessionTimeout?: number
@@ -162,9 +159,7 @@ export class ConfigService {
162159
this.setConfigForDocker()
163160
}
164161

165-
if (this.serviceMode) {
166-
this.setConfigForServiceMode()
167-
}
162+
this.setConfig()
168163

169164
if (!this.ui.port) {
170165
this.ui.port = 8080
@@ -205,7 +200,6 @@ export class ConfigService {
205200
packageVersion: this.package.version,
206201
platform: platform(),
207202
port: this.ui.port,
208-
serviceMode: this.serviceMode,
209203
setupWizardComplete: this.setupWizardComplete,
210204
},
211205
formAuth: Boolean(this.ui.auth !== 'none'),
@@ -298,9 +292,9 @@ export class ConfigService {
298292
}
299293

300294
/**
301-
* Populate the required config when running in "Service Mode"
295+
* Populate the required config
302296
*/
303-
private setConfigForServiceMode() {
297+
private setConfig() {
304298
this.homebridgeInsecureMode = Boolean(process.env.UIX_INSECURE_MODE === '1')
305299
this.ui.restart = undefined
306300
this.ui.sudo = (platform() === 'linux' && !this.runningInDocker && !this.runningInSynologyPackage && !this.runningInPackageMode) || platform() === 'freebsd'

src/index.ts

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
* Homebridge Entry Point
33
*/
44

5-
import { fork } from 'node:child_process'
6-
import { resolve } from 'node:path'
75
import process from 'node:process'
86

97
import { Command } from 'commander'
@@ -35,57 +33,6 @@ class HomebridgeUi {
3533
log.error(msg)
3634
log.warn(msg)
3735
}
38-
39-
if (process.env.UIX_SERVICE_MODE === '1' && process.connected) {
40-
this.log('Running in service mode.')
41-
} else if (config.standalone || process.env.UIX_SERVICE_MODE === '1'
42-
|| (process.env.HOMEBRIDGE_CONFIG_UI === '1' && satisfies(process.env.CONFIG_UI_VERSION, '>=3.5.5', { includePrerelease: true }))) {
43-
this.log.warn('*********** Homebridge Standalone Mode Is Deprecated **********')
44-
this.log.warn('* Please swap to service mode using the hb-service command. *')
45-
this.log.warn('* See https://homebridge.io/w/JUvQr for instructions on how to migrate. *')
46-
this.log('Running in standalone mode.')
47-
} else if (config.noFork) {
48-
this.noFork()
49-
} else {
50-
this.fork()
51-
}
52-
}
53-
54-
/**
55-
* Run plugin as a separate node.js process
56-
*/
57-
fork() {
58-
const ui = fork(resolve(__dirname, 'bin/fork'), null, {
59-
env: process.env,
60-
})
61-
62-
this.log('Spawning Homebridge UI with PID', ui.pid)
63-
64-
ui.on('close', () => {
65-
process.kill(process.pid, 'SIGTERM')
66-
})
67-
68-
ui.on('error', () => {
69-
// Do nothing
70-
})
71-
}
72-
73-
/**
74-
* Run plugin in the main homebridge process
75-
*/
76-
async noFork() {
77-
await import('./main')
78-
}
79-
80-
/**
81-
* Set up the service mode process helper
82-
* This ensures the Homebridge process is killed when hb-service
83-
* is killed with SIGTERM to prevent stale processes.
84-
*/
85-
static serviceMode() {
86-
process.on('disconnect', () => {
87-
process.exit()
88-
})
8936
}
9037

9138
accessories(callback) {
@@ -98,8 +45,5 @@ class HomebridgeUi {
9845
export = (api) => {
9946
homebridge = api
10047
homebridge.registerPlatform('homebridge-config-ui-x', 'config', HomebridgeUi)
101-
102-
if (process.env.UIX_SERVICE_MODE === '1' && process.connected) {
103-
HomebridgeUi.serviceMode()
104-
}
48+
process.on('disconnect', () => process.exit())
10549
}

0 commit comments

Comments
 (0)