]>
Commit | Line | Data |
---|---|---|
8822ebee | 1 | /* |
f6e9a3ee | 2 | * Copyright (C) 1996-2019 The Squid Software Foundation and contributors |
8822ebee | 3 | * |
bbc27441 AJ |
4 | * Squid software is distributed under GPLv2+ license and includes |
5 | * contributions from numerous individuals and organizations. | |
6 | * Please see the COPYING and CONTRIBUTORS files for details. | |
8822ebee AR |
7 | */ |
8 | ||
bbc27441 AJ |
9 | /* DEBUG: section 16 Cache Manager API */ |
10 | ||
f7f3304a | 11 | #include "squid.h" |
8822ebee AR |
12 | #include "base/TextException.h" |
13 | #include "CacheManager.h" | |
14 | #include "mgr/ActionCreator.h" | |
15 | #include "mgr/ActionProfile.h" | |
16 | #include "mgr/BasicActions.h" | |
17 | #include "mgr/Registration.h" | |
582c2af2 | 18 | #include "protos.h" |
4d5904f7 | 19 | #include "SquidConfig.h" |
602d9612 | 20 | #include "Store.h" |
8822ebee | 21 | |
b073fc4b AJ |
22 | Mgr::IndexAction::Pointer |
23 | Mgr::IndexAction::Create(const Command::Pointer &cmd) | |
24 | { | |
25 | return new IndexAction(cmd); | |
26 | } | |
27 | ||
9dca980d | 28 | Mgr::IndexAction::IndexAction(const Command::Pointer &aCmd): Action(aCmd) |
b073fc4b AJ |
29 | { |
30 | debugs(16, 5, HERE); | |
31 | } | |
32 | ||
33 | void | |
ced8def3 | 34 | Mgr::IndexAction::dump(StoreEntry *) |
b073fc4b AJ |
35 | { |
36 | debugs(16, 5, HERE); | |
37 | } | |
38 | ||
8822ebee AR |
39 | Mgr::MenuAction::Pointer |
40 | Mgr::MenuAction::Create(const Command::Pointer &cmd) | |
41 | { | |
42 | return new MenuAction(cmd); | |
43 | } | |
44 | ||
9dca980d | 45 | Mgr::MenuAction::MenuAction(const Command::Pointer &aCmd): Action(aCmd) |
8822ebee AR |
46 | { |
47 | debugs(16, 5, HERE); | |
48 | } | |
49 | ||
50 | void | |
51 | Mgr::MenuAction::dump(StoreEntry* entry) | |
52 | { | |
53 | debugs(16, 5, HERE); | |
54 | Must(entry != NULL); | |
55 | ||
56 | typedef CacheManager::Menu::const_iterator Iterator; | |
57 | const CacheManager::Menu& menu = CacheManager::GetInstance()->menu(); | |
58 | ||
59 | for (Iterator a = menu.begin(); a != menu.end(); ++a) { | |
60 | storeAppendPrintf(entry, " %-22s\t%-32s\t%s\n", | |
61 | (*a)->name, (*a)->desc, | |
62 | CacheManager::GetInstance()->ActionProtection(*a)); | |
63 | } | |
64 | } | |
65 | ||
66 | Mgr::ShutdownAction::Pointer | |
67 | Mgr::ShutdownAction::Create(const Command::Pointer &cmd) | |
68 | { | |
69 | return new ShutdownAction(cmd); | |
70 | } | |
71 | ||
9dca980d | 72 | Mgr::ShutdownAction::ShutdownAction(const Command::Pointer &aCmd): Action(aCmd) |
8822ebee AR |
73 | { |
74 | debugs(16, 5, HERE); | |
75 | } | |
76 | ||
77 | void | |
ced8def3 | 78 | Mgr::ShutdownAction::dump(StoreEntry *) |
8822ebee AR |
79 | { |
80 | debugs(16, DBG_CRITICAL, "Shutdown by Cache Manager command."); | |
81 | shut_down(SIGTERM); | |
82 | } | |
83 | ||
84 | Mgr::ReconfigureAction::Pointer | |
85 | Mgr::ReconfigureAction::Create(const Command::Pointer &cmd) | |
86 | { | |
87 | return new ReconfigureAction(cmd); | |
88 | } | |
89 | ||
9dca980d | 90 | Mgr::ReconfigureAction::ReconfigureAction(const Command::Pointer &aCmd): |
f53969cc | 91 | Action(aCmd) |
8822ebee AR |
92 | { |
93 | debugs(16, 5, HERE); | |
94 | } | |
95 | ||
96 | void | |
97 | Mgr::ReconfigureAction::dump(StoreEntry* entry) | |
98 | { | |
99 | debugs(16, DBG_IMPORTANT, "Reconfigure by Cache Manager command."); | |
100 | storeAppendPrintf(entry, "Reconfiguring Squid Process ...."); | |
101 | reconfigure(SIGHUP); | |
102 | } | |
103 | ||
104 | Mgr::RotateAction::Pointer | |
105 | Mgr::RotateAction::Create(const Command::Pointer &cmd) | |
106 | { | |
107 | return new RotateAction(cmd); | |
108 | } | |
109 | ||
9dca980d | 110 | Mgr::RotateAction::RotateAction(const Command::Pointer &aCmd): Action(aCmd) |
8822ebee AR |
111 | { |
112 | debugs(16, 5, HERE); | |
113 | } | |
114 | ||
115 | void | |
116 | Mgr::RotateAction::dump(StoreEntry* entry) | |
117 | { | |
118 | debugs(16, DBG_IMPORTANT, "Rotate Logs by Cache Manager command."); | |
119 | storeAppendPrintf(entry, "Rotating Squid Process Logs ...."); | |
605f2c3e | 120 | #if defined(_SQUID_LINUX_THREADS_) |
8822ebee AR |
121 | rotate_logs(SIGQUIT); |
122 | #else | |
123 | rotate_logs(SIGUSR1); | |
124 | #endif | |
125 | } | |
126 | ||
127 | Mgr::OfflineToggleAction::Pointer | |
128 | Mgr::OfflineToggleAction::Create(const Command::Pointer &cmd) | |
129 | { | |
130 | return new OfflineToggleAction(cmd); | |
131 | } | |
132 | ||
9dca980d | 133 | Mgr::OfflineToggleAction::OfflineToggleAction(const Command::Pointer &aCmd): |
f53969cc | 134 | Action(aCmd) |
8822ebee AR |
135 | { |
136 | debugs(16, 5, HERE); | |
137 | } | |
138 | ||
139 | void | |
140 | Mgr::OfflineToggleAction::dump(StoreEntry* entry) | |
141 | { | |
142 | Config.onoff.offline = !Config.onoff.offline; | |
143 | debugs(16, DBG_IMPORTANT, "offline_mode now " << (Config.onoff.offline ? "ON" : "OFF") << " by Cache Manager request."); | |
144 | ||
145 | storeAppendPrintf(entry, "offline_mode is now %s\n", | |
146 | Config.onoff.offline ? "ON" : "OFF"); | |
147 | } | |
148 | ||
149 | void | |
150 | Mgr::RegisterBasics() | |
151 | { | |
b073fc4b AJ |
152 | RegisterAction("index", "Cache Manager Interface", &Mgr::IndexAction::Create, 0, 1); |
153 | RegisterAction("menu", "Cache Manager Menu", &Mgr::MenuAction::Create, 0, 1); | |
8822ebee AR |
154 | RegisterAction("offline_toggle", "Toggle offline_mode setting", &Mgr::OfflineToggleAction::Create, 1, 1); |
155 | RegisterAction("shutdown", "Shut Down the Squid Process", &Mgr::ShutdownAction::Create, 1, 1); | |
156 | RegisterAction("reconfigure", "Reconfigure Squid", &Mgr::ReconfigureAction::Create, 1, 1); | |
157 | RegisterAction("rotate", "Rotate Squid Logs", &Mgr::RotateAction::Create, 1, 1); | |
8822ebee | 158 | } |
f53969cc | 159 |