1 00:00:06,690 --> 00:00:09,390 - So while working with system D in many cases 2 00:00:09,390 --> 00:00:12,240 you will just use the default service configuration 3 00:00:12,240 --> 00:00:14,370 but I want to show you how you can modify 4 00:00:14,370 --> 00:00:16,230 service configuration. 5 00:00:16,230 --> 00:00:19,230 You should always start using system CTL Cat on the 6 00:00:19,230 --> 00:00:23,640 service. That will show you the current unit configuration. 7 00:00:23,640 --> 00:00:26,250 Of course, there's a configuration fell behind it. 8 00:00:26,250 --> 00:00:27,630 But the thing in system D is 9 00:00:27,630 --> 00:00:31,260 that there can be multiple configuration fells behind it. 10 00:00:31,260 --> 00:00:33,360 And if you use system CTL cat 11 00:00:33,360 --> 00:00:36,870 now you are just going to get all the configuration fells 12 00:00:36,870 --> 00:00:38,763 that this service is using. 13 00:00:40,050 --> 00:00:40,883 You wanna know 14 00:00:40,883 --> 00:00:44,850 about configurable parameters, your system, CTL show. 15 00:00:44,850 --> 00:00:47,760 And once you have found your configurable parameter 16 00:00:47,760 --> 00:00:51,900 you can use system CTL edit on your service. 17 00:00:51,900 --> 00:00:54,730 And after modifying your service configuration 18 00:00:54,730 --> 00:00:58,830 it is good to tell system D to reload its configuration 19 00:00:58,830 --> 00:01:01,440 system CTL daemon reload 20 00:01:01,440 --> 00:01:04,680 that will force system D to reload its configuration. 21 00:01:04,680 --> 00:01:06,450 You will notice that in modern versions 22 00:01:06,450 --> 00:01:09,330 of system D that's not always necessary anymore 23 00:01:09,330 --> 00:01:11,338 but especially in older versions 24 00:01:11,338 --> 00:01:14,430 this might be something that you wanna do. 25 00:01:14,430 --> 00:01:19,410 And system CTR restart on your service is what 26 00:01:19,410 --> 00:01:21,600 you want to do to restart the service 27 00:01:21,600 --> 00:01:23,490 if it was already running. 28 00:01:23,490 --> 00:01:24,393 Let me show you. 29 00:01:27,720 --> 00:01:30,960 So I'm going to start using system CTL Cat 30 00:01:30,960 --> 00:01:34,233 on SS H D dot service. 31 00:01:35,790 --> 00:01:40,470 This is a sent OS system and SSH is running by default. 32 00:01:40,470 --> 00:01:41,790 So what do we see? 33 00:01:41,790 --> 00:01:44,580 We see that SSH is using user lip system D 34 00:01:44,580 --> 00:01:46,350 system SSHD dot service. 35 00:01:46,350 --> 00:01:48,360 That's the configuration file. 36 00:01:48,360 --> 00:01:50,280 We have the unit configuration 37 00:01:50,280 --> 00:01:51,810 and in the unit configuration 38 00:01:51,810 --> 00:01:54,840 you have generic stuff, including the dependencies. 39 00:01:54,840 --> 00:01:57,000 And now we have the service configuration 40 00:01:57,000 --> 00:02:01,620 in which you specify exactly what should be happening. 41 00:02:01,620 --> 00:02:02,700 Now, what I'm interested 42 00:02:02,700 --> 00:02:06,000 in is this restart on and restart sec. 43 00:02:06,000 --> 00:02:07,560 And I'm going to copy that 44 00:02:07,560 --> 00:02:11,970 and let me use sudo systems CTL edit 45 00:02:11,970 --> 00:02:15,990 on httpd dot service, well dot service 46 00:02:15,990 --> 00:02:18,810 you don't even have to type dot service. 47 00:02:18,810 --> 00:02:22,500 If you just type system CTL edit httpd, it'll 48 00:02:22,500 --> 00:02:25,830 automatically assume that you want to edit a service. 49 00:02:25,830 --> 00:02:26,700 And here we go. 50 00:02:26,700 --> 00:02:27,780 And we are 51 00:02:27,780 --> 00:02:32,780 in the default system D editor, which is, which is nano. 52 00:02:34,500 --> 00:02:36,272 Now read carefully. 53 00:02:36,272 --> 00:02:37,350 What do we see? 54 00:02:37,350 --> 00:02:39,930 We see anything between here and a comment below 55 00:02:39,930 --> 00:02:41,790 will become the new contents of the valve. 56 00:02:41,790 --> 00:02:43,488 That's exactly what I need. 57 00:02:43,488 --> 00:02:46,950 So we can see right here 58 00:02:46,950 --> 00:02:50,160 lines below the comment will be discarded. 59 00:02:50,160 --> 00:02:51,360 Then why are they there? 60 00:02:51,360 --> 00:02:53,400 Well, because they allow you to see 61 00:02:53,400 --> 00:02:56,280 what you currently have in your configuration. 62 00:02:56,280 --> 00:02:59,040 Now I'm going to paste and in my paste 63 00:02:59,040 --> 00:03:04,040 I'm using restart on failure and restart sec is 42 seconds. 64 00:03:04,560 --> 00:03:08,193 And I want to put that in the service section. 65 00:03:09,840 --> 00:03:11,490 Now I'm going to use cultural X 66 00:03:11,490 --> 00:03:13,230 to write the modified buffer. 67 00:03:13,230 --> 00:03:14,640 And there we go. 68 00:03:14,640 --> 00:03:17,820 And I am going to use system CTL cat 69 00:03:17,820 --> 00:03:19,500 on httpd. 70 00:03:19,500 --> 00:03:22,410 And what is system Key CTL cat showing? 71 00:03:22,410 --> 00:03:25,590 It's showing the context of httpd dot service. 72 00:03:25,590 --> 00:03:28,170 That's the default configuration. 73 00:03:28,170 --> 00:03:31,260 And to the end, it is also showing my additions 74 00:03:31,260 --> 00:03:34,920 and my additions have been added in ETC system D system 75 00:03:34,920 --> 00:03:38,580 in a sub directory and in their override.com. 76 00:03:38,580 --> 00:03:41,400 So this override.com is automatically applied 77 00:03:41,400 --> 00:03:43,830 to the httpd dot service. 78 00:03:43,830 --> 00:03:45,240 So I have my researchers 79 00:03:45,240 --> 00:03:48,513 on failure and the research sec is 42 seconds. 80 00:03:49,500 --> 00:03:50,333 Is that okay? 81 00:03:50,333 --> 00:03:52,560 Well, I can live with that 82 00:03:52,560 --> 00:03:57,383 and let me do a sudo system CTL start on httpd. 83 00:03:58,650 --> 00:04:03,063 And now let me do sudo kill all httpd. 84 00:04:04,200 --> 00:04:08,490 and sudo system CTL status on httpd. 85 00:04:08,490 --> 00:04:11,940 And then we need to figure out what is happening. 86 00:04:11,940 --> 00:04:12,840 So what do we see? 87 00:04:12,840 --> 00:04:16,260 We see that the service is inactive in that, and oh 88 00:04:16,260 --> 00:04:17,400 that is not good. 89 00:04:17,400 --> 00:04:20,370 Hey, you know what system D doesn't know 90 00:04:20,370 --> 00:04:22,410 about its new option, apparently. 91 00:04:22,410 --> 00:04:24,300 So let's tell it about it. 92 00:04:24,300 --> 00:04:28,801 I'm first going to use system CTL, start on httpd again 93 00:04:28,801 --> 00:04:31,530 and this looks like one of these cases where 94 00:04:31,530 --> 00:04:35,880 we need sudo system CTL daemon reload 95 00:04:35,880 --> 00:04:37,380 which is their system D 96 00:04:37,380 --> 00:04:40,950 can you please reload your configuration? 97 00:04:40,950 --> 00:04:44,580 Now I'm using system CTL status, and I'm looking 98 00:04:44,580 --> 00:04:49,580 at PID4938, and I'm going to sudo kill minus nine. 99 00:04:50,250 --> 00:04:52,770 That's a command that I will explain later in much 100 00:04:52,770 --> 00:04:57,633 more detail, but I'm killing minus nine, the process 4938. 101 00:04:58,620 --> 00:05:01,350 And now I'm going to use my status again to 102 00:05:01,350 --> 00:05:04,110 see what is going on. 103 00:05:04,110 --> 00:05:06,300 And now we can see it's working. 104 00:05:06,300 --> 00:05:07,380 Do you see that 105 00:05:07,380 --> 00:05:08,880 active is now set 106 00:05:08,880 --> 00:05:11,940 to activating auto restart? 107 00:05:11,940 --> 00:05:13,140 So what does that mean? 108 00:05:13,140 --> 00:05:14,940 That means that the option that I have just 109 00:05:14,940 --> 00:05:19,470 applied is adding protection to the service. 110 00:05:19,470 --> 00:05:22,230 If something bad happens to the service system 111 00:05:22,230 --> 00:05:23,340 D can make sure 112 00:05:23,340 --> 00:05:26,280 that the service is automatically started again. 113 00:05:26,280 --> 00:05:30,210 And this is one of the most awesome features in system D 114 00:05:30,210 --> 00:05:33,210 because before system D if you wanted to add protection 115 00:05:33,210 --> 00:05:37,050 like this to a service, then you really only had one choice 116 00:05:37,050 --> 00:05:40,200 and that is to install a high availability closer. 117 00:05:40,200 --> 00:05:41,246 Now, you don't have to do 118 00:05:41,246 --> 00:05:44,070 a high availability closer anymore. 119 00:05:44,070 --> 00:05:48,240 You just use the system D restart equals 120 00:05:48,240 --> 00:05:51,900 on failure and restart number of seconds 121 00:05:51,900 --> 00:05:54,360 and it'll automatically get back. 122 00:05:54,360 --> 00:05:55,680 Do we already have it? 123 00:05:55,680 --> 00:05:56,513 There we go. 124 00:05:56,513 --> 00:05:58,110 We already have it. 125 00:05:58,110 --> 00:06:01,530 So system D made sure it's automatically started again 126 00:06:01,530 --> 00:06:03,960 and this is just one of the many nice features 127 00:06:03,960 --> 00:06:07,680 of system D. I can talk about system D for hours. 128 00:06:07,680 --> 00:06:09,390 That's not my intention here 129 00:06:09,390 --> 00:06:11,643 so let's continue with the next video.