We have a requirement where multiple application versions can be installed simultaneously on a system.
There exists a boot-loader.conf file that lists app versions along with a config file for each version associated to a boot-priority.
The requirement is to iterate over this file and
- start an app version at the least boot-priority with specified config file
- if app fails to start, iterate to next app version
- if app starts successfully and later is killed/crashes, restart the app (of earlier running version)
To achieve this on CentOS 6, following sys V init scripts were written
- boot-loader service (iterates over boot-loader.conf file and starts the app service)
- app service (starts the app with appropriate config file)
- boot-loader waits till the app service is started successfully
- monit was used to monitor the app service and restart if not running
Note: Both boot-loader and monit used 'service app start' to start the app.
With CentOS 7 and systemd, we thought of getting rid of monit and use systemd integrated service monitoring.
Hence the init scripts were migrated to
- boot-loader service with type=oneshot and RemainAfterExit
- app service with type=simple, After=boot-loader.service and Restart=always
Somehow, these seem to not work, since the boot-loader needs to wait for the app to successfully start and the app is not started till boot-loader exits.
What are the possible ways to implement such a behaviour?
Systemd service for boot-loader kind of implementation
-
- Posts: 1
- Joined: 2018/02/13 11:38:43
-
- Posts: 2019
- Joined: 2015/02/17 15:14:33
- Location: Bulgaria
- Contact:
Re: Systemd service for boot-loader kind of implementation
This line
indicates that boot-loader should be over before starting your service.
Maybe the easiest way should be boot-loader to call the app service, but this means to incorporate a watchdog.
I think that there is a flaw in the design and most probably creation of single app service with would do as intended, but the logic should be adapted.
Code: Select all
After=boot-loader.service
Maybe the easiest way should be boot-loader to call the app service, but this means to incorporate a watchdog.
I think that there is a flaw in the design and most probably creation of single app service with
Code: Select all
ExecStartPre=boot-loader-script &