- Edited
Today I want to write about how to make good sense of service trees in Obarun with a little example.
PREAMBLE
We will look at a frontend-dev/webdesigner/farmer who wants to set up his system for web development.
He usually used LAMP back in the days on his then brand new 2006 MacBook Pro 2.1 and also on his Hackintosh throughout the years.
When he changed to Linux he got to know about nginx and now also sometimes developed on top of that.
So he'd probably make a choice: Either use httpd or nginx. Why not use both whenever he wanted to?
Well that is because he would have to enable several services to deal with the server daemons to begin with his frontend wizardry.
USUAL SETUP WITH MAJOR SERVICE MANAGERS
So he would install all the necessary services and then enable them. Depending on his system he would need to instruct one of sysVinit, systemd, launchd, upstart or some other service manager to enable and start each service.
For his LAMP stack he'd need (services, not packages): httpd, mysqld and a few lines of config file edits.
For his LEMP stack he'd need (services, not packages): nginx, mysqld, php-fpm and a few lines of config file edits.
Now he cannot just enable all of these services alongside each other and get right at it because that would need a ton of configuration expertise to make the httpd server available at one address, the nginx at another, the mysql database not mix up everything and have php serve two servers at the same time. (Sounds like two months of investigating/learning/deploying).
So what he'll do is he'll make a choice. Either enable services for LAMP or for LEMP. He decides to go with LAMP because well, that's what he always used so what gives. Might as well stick to it.
He'd then
So now he'd
THE 66 WAY
But today he was reading this forum where he found out about a different service manager that would allow to have either stack with just a oneliner from his shell. It's called 66. It's a customized wrapper around the s6 init system and service manager that's only available on Obarun Linux for now but could easily be installed on any Linux.
What is different?
66 will conveniently let him create trees for whatever services he'd like and individually allow him to enable or disable the whole tree. As a developer his mouth got instantly wet by knowing only that.
Why does this matter?
Because now he can think in his own terms.
He will separate things into chunks and serve them only when he wants to.
To try it out he created a tree named `apache` and another tree called `nginx` and enabled the corresponding services on top of each:
No reboot required, everything will be available right away.
SOME DETAILS
In this example both trees share a service called `mysqld`. It was manually enabled on both. When either tree gets initialized this shared service becomes flagged with a PID on both trees. That is because, well, it's a running process right? But since the other tree is kept disabled/uninitialized its individual non-shared services also are kept deactivated. This is a great example of how to make chunks of services to serve a very specific use in a specific moment without having to worry too much about other services interfering or what services are needed and what not as long as you keep these chunks sorted. Because we all know: Services add up real quick.
DISCLAIMER
This write up is not protected under any copyright law of any country throughout the world. Country of first publication: Mexico. Any unauthorized exhibition, distribution, or copying of this text or any part thereof (including symbols) may result in publicity for 66. The story, all names, characters, and incidents portrayed in this text are fictitious. No identification with actual persons (living or deceased), places, buildings, and products is intended or should be inferred. No person or entity associated with this text received payment or anything of value, or entered into any agreement, in connection with the depiction of Linux products. No processors were harmed in the making of this text.
PREAMBLE
We will look at a frontend-dev/webdesigner/farmer who wants to set up his system for web development.
He usually used LAMP back in the days on his then brand new 2006 MacBook Pro 2.1 and also on his Hackintosh throughout the years.
When he changed to Linux he got to know about nginx and now also sometimes developed on top of that.
So he'd probably make a choice: Either use httpd or nginx. Why not use both whenever he wanted to?
Well that is because he would have to enable several services to deal with the server daemons to begin with his frontend wizardry.
USUAL SETUP WITH MAJOR SERVICE MANAGERS
So he would install all the necessary services and then enable them. Depending on his system he would need to instruct one of sysVinit, systemd, launchd, upstart or some other service manager to enable and start each service.
For his LAMP stack he'd need (services, not packages): httpd, mysqld and a few lines of config file edits.
For his LEMP stack he'd need (services, not packages): nginx, mysqld, php-fpm and a few lines of config file edits.
Now he cannot just enable all of these services alongside each other and get right at it because that would need a ton of configuration expertise to make the httpd server available at one address, the nginx at another, the mysql database not mix up everything and have php serve two servers at the same time. (Sounds like two months of investigating/learning/deploying).
So what he'll do is he'll make a choice. Either enable services for LAMP or for LEMP. He decides to go with LAMP because well, that's what he always used so what gives. Might as well stick to it.
He'd then
- Enable all the necessary services (2) and edit the config files
- Start the enabled services (2)
- Go do some magic
So now he'd
- Remember what services were needed for his LAMP stack (2)
- Maybe remember that one service is shared by both and let it be
- Stop all the LAMP services (2)
- Disable them (2)
- He's busy today, accidentally also disabled mysql...
- Remember what services were needed for his LEMP stack (3)
- Enable all the LEMP sercvices (3)
- Mysql anyone?...
- Go do some more magic
THE 66 WAY
But today he was reading this forum where he found out about a different service manager that would allow to have either stack with just a oneliner from his shell. It's called 66. It's a customized wrapper around the s6 init system and service manager that's only available on Obarun Linux for now but could easily be installed on any Linux.
What is different?
66 will conveniently let him create trees for whatever services he'd like and individually allow him to enable or disable the whole tree. As a developer his mouth got instantly wet by knowing only that.
Why does this matter?
Because now he can think in his own terms.
He will separate things into chunks and serve them only when he wants to.
To try it out he created a tree named `apache` and another tree called `nginx` and enabled the corresponding services on top of each:
frontendwizard@ obarun ~ % sudo 66-tree -n apache && sudo 66-tree -n nginx
frontendwizard@ obarun ~ % sudo 66-enable -t apache mysqld httpd && sudo 66-enable -t nginx msyqld nginx php-fpm
Now he wants to use LAMP right away and not activate it on each reboot so he enables that tree and starts its services:
frontendwizard@ obarun ~ % sudo 66-tree -E apache && sudo 66-all -t apache up
And when he wants to switch to LEMP (given that he already activated the LAMP stack before):
# stop and disable apache:
frontendwizard@ obarun ~ % sudo 66-all -t apache down && sudo 66-tree -D apache
# enable and start nginx:
frontendwizard@ obarun ~ % sudo 66-tree -E nginx && sudo 66-all -t nginx up
(Five relatively short lines of code to do all the same from above.)No reboot required, everything will be available right away.
SOME DETAILS
In this example both trees share a service called `mysqld`. It was manually enabled on both. When either tree gets initialized this shared service becomes flagged with a PID on both trees. That is because, well, it's a running process right? But since the other tree is kept disabled/uninitialized its individual non-shared services also are kept deactivated. This is a great example of how to make chunks of services to serve a very specific use in a specific moment without having to worry too much about other services interfering or what services are needed and what not as long as you keep these chunks sorted. Because we all know: Services add up real quick.
DISCLAIMER
This write up is not protected under any copyright law of any country throughout the world. Country of first publication: Mexico. Any unauthorized exhibition, distribution, or copying of this text or any part thereof (including symbols) may result in publicity for 66. The story, all names, characters, and incidents portrayed in this text are fictitious. No identification with actual persons (living or deceased), places, buildings, and products is intended or should be inferred. No person or entity associated with this text received payment or anything of value, or entered into any agreement, in connection with the depiction of Linux products. No processors were harmed in the making of this text.