Score:0

RHEL 7 systemctl: Combine multiple services into one. start the service independently

id flag

I have followed the steps from RedHat to start the multiple services into one service. https://access.redhat.com/solutions/3097871

/etc/systemd/system/myapps.target

[Unit]
Description=App Service Unit

# This collection of apps should be started at boot time.
[Install]
WantedBy=multi-user.target

App1.service

/etc/systemd/system/app1.service

[Unit]
Description= Instance of App1 Service
PartOf=myapps.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/home/mark/bin/app1.sh start
ExecStop=/home/mark/bin/app1.sh stop

# When the service runs globally, make it run as a particular user for added security
#User=user1
#Group=group1

# When systemctl enable is used, make this start when the App service starts
[Install]
WantedBy=myapps.target

App2.service

  [Unit]
Description= Instance of App2 Service
PartOf=myapps.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/home/mark/bin/app2.sh start
ExecStop=/home/mark/bin/app2.sh stop

# When the service runs globally, make it run as a particular user for added security
#User=user1
#Group=group1

[Install]
WantedBy=myapps.target

I want to stop the app1.service independently. But when I check the status of the myapps.target, I do not see the current app1.service status as stopped. Instead, it shows that app1.service is running. How can I change myapps.target to reflect the status?

Thanks in advance.

user1686 avatar
fr flag
Why are they "Type=oneshot" services?
id flag
Thank you for your reply. These are the sample services. Will it cause any issue when used with Type=oneshot?
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.