mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-02-21 10:01:55 +00:00
Only install service if running is set to false
The supervisor supports target state `running: false` for services. This state indicates that the service should be stopped if already running, or that the container should just be created and never started if the container does not exist. This commit fixes the latter behavior. Although nothing in our platform currently sends this target state, this enables some potential use cases, e.g. only starting some services in manufacturing and starting the rest of the services when the device actually connects. Change-type: patch Closes: #2014
This commit is contained in:
parent
2ec9274b78
commit
c6f911c36b
@ -298,6 +298,15 @@ export async function start(service: Service) {
|
||||
|
||||
try {
|
||||
const container = await create(service);
|
||||
|
||||
// Exit here if the target state of the service
|
||||
// is set to running: false
|
||||
// QUESTION: should we split the service steps into
|
||||
// 'install' and 'start' instead of doing this?
|
||||
if (service.config.running === false) {
|
||||
return container;
|
||||
}
|
||||
|
||||
containerId = container.id;
|
||||
logger.logSystemEvent(LogTypes.startService, { service });
|
||||
|
||||
@ -310,6 +319,7 @@ export async function start(service: Service) {
|
||||
} catch (e) {
|
||||
// Get the statusCode from the original cause and make sure it's
|
||||
// definitely an int for comparison reasons
|
||||
// QUESTION: does this ever happen?
|
||||
const maybeStatusCode = PermissiveNumber.decode(e.statusCode);
|
||||
if (isLeft(maybeStatusCode)) {
|
||||
shouldRemove = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user