- So while working with system D in many cases
you will just use the default service configuration
but I want to show you how you can modify
service configuration.
You should always start using system CTL Cat on the
service. That will show you the current unit configuration.
Of course, there's a configuration fell behind it.
But the thing in system D is
that there can be multiple configuration fells behind it.
And if you use system CTL cat
now you are just going to get all the configuration fells
that this service is using.
You wanna know
about configurable parameters, your system, CTL show.
And once you have found your configurable parameter
you can use system CTL edit on your service.
And after modifying your service configuration
it is good to tell system D to reload its configuration
system CTL daemon reload
that will force system D to reload its configuration.
You will notice that in modern versions
of system D that's not always necessary anymore
but especially in older versions
this might be something that you wanna do.
And system CTR restart on your service is what
you want to do to restart the service
if it was already running.
Let me show you.
So I'm going to start using system CTL Cat
on SS H D dot service.
This is a sent OS system and SSH is running by default.
So what do we see?
We see that SSH is using user lip system D
system SSHD dot service.
That's the configuration file.
We have the unit configuration
and in the unit configuration
you have generic stuff, including the dependencies.
And now we have the service configuration
in which you specify exactly what should be happening.
Now, what I'm interested
in is this restart on and restart sec.
And I'm going to copy that
and let me use sudo systems CTL edit
on httpd dot service, well dot service
you don't even have to type dot service.
If you just type system CTL edit httpd, it'll
automatically assume that you want to edit a service.
And here we go.
And we are
in the default system D editor, which is, which is nano.
Now read carefully.
What do we see?
We see anything between here and a comment below
will become the new contents of the valve.
That's exactly what I need.
So we can see right here
lines below the comment will be discarded.
Then why are they there?
Well, because they allow you to see
what you currently have in your configuration.
Now I'm going to paste and in my paste
I'm using restart on failure and restart sec is 42 seconds.
And I want to put that in the service section.
Now I'm going to use cultural X
to write the modified buffer.
And there we go.
And I am going to use system CTL cat
on httpd.
And what is system Key CTL cat showing?
It's showing the context of httpd dot service.
That's the default configuration.
And to the end, it is also showing my additions
and my additions have been added in ETC system D system
in a sub directory and in their override.com.
So this override.com is automatically applied
to the httpd dot service.
So I have my researchers
on failure and the research sec is 42 seconds.
Is that okay?
Well, I can live with that
and let me do a sudo system CTL start on httpd.
And now let me do sudo kill all httpd.
and sudo system CTL status on httpd.
And then we need to figure out what is happening.
So what do we see?
We see that the service is inactive in that, and oh
that is not good.
Hey, you know what system D doesn't know
about its new option, apparently.
So let's tell it about it.
I'm first going to use system CTL, start on httpd again
and this looks like one of these cases where
we need sudo system CTL daemon reload
which is their system D
can you please reload your configuration?
Now I'm using system CTL status, and I'm looking
at PID4938, and I'm going to sudo kill minus nine.
That's a command that I will explain later in much
more detail, but I'm killing minus nine, the process 4938.
And now I'm going to use my status again to
see what is going on.
And now we can see it's working.
Do you see that
active is now set
to activating auto restart?
So what does that mean?
That means that the option that I have just
applied is adding protection to the service.
If something bad happens to the service system
D can make sure
that the service is automatically started again.
And this is one of the most awesome features in system D
because before system D if you wanted to add protection
like this to a service, then you really only had one choice
and that is to install a high availability closer.
Now, you don't have to do
a high availability closer anymore.
You just use the system D restart equals
on failure and restart number of seconds
and it'll automatically get back.
Do we already have it?
There we go.
We already have it.
So system D made sure it's automatically started again
and this is just one of the many nice features
of system D. I can talk about system D for hours.
That's not my intention here
so let's continue with the next video.