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