]> git.ipfire.org Git - thirdparty/squid.git/blame - src/mgr/BasicActions.cc
Renamed squid.h to squid-old.h and config.h to squid.h
[thirdparty/squid.git] / src / mgr / BasicActions.cc
CommitLineData
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
18Mgr::IndexAction::Pointer
19Mgr::IndexAction::Create(const Command::Pointer &cmd)
20{
21 return new IndexAction(cmd);
22}
23
24Mgr::IndexAction::IndexAction(const Command::Pointer &cmd): Action(cmd)
25{
26 debugs(16, 5, HERE);
27}
28
29void
30Mgr::IndexAction::dump(StoreEntry* entry)
31{
32 debugs(16, 5, HERE);
33}
34
8822ebee
AR
35Mgr::MenuAction::Pointer
36Mgr::MenuAction::Create(const Command::Pointer &cmd)
37{
38 return new MenuAction(cmd);
39}
40
41Mgr::MenuAction::MenuAction(const Command::Pointer &cmd): Action(cmd)
42{
43 debugs(16, 5, HERE);
44}
45
46void
47Mgr::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
62Mgr::ShutdownAction::Pointer
63Mgr::ShutdownAction::Create(const Command::Pointer &cmd)
64{
65 return new ShutdownAction(cmd);
66}
67
68Mgr::ShutdownAction::ShutdownAction(const Command::Pointer &cmd): Action(cmd)
69{
70 debugs(16, 5, HERE);
71}
72
73void
74Mgr::ShutdownAction::dump(StoreEntry* entry)
75{
76 debugs(16, DBG_CRITICAL, "Shutdown by Cache Manager command.");
77 shut_down(SIGTERM);
78}
79
80Mgr::ReconfigureAction::Pointer
81Mgr::ReconfigureAction::Create(const Command::Pointer &cmd)
82{
83 return new ReconfigureAction(cmd);
84}
85
86Mgr::ReconfigureAction::ReconfigureAction(const Command::Pointer &cmd):
d9fc6862 87 Action(cmd)
8822ebee
AR
88{
89 debugs(16, 5, HERE);
90}
91
92void
93Mgr::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
100Mgr::RotateAction::Pointer
101Mgr::RotateAction::Create(const Command::Pointer &cmd)
102{
103 return new RotateAction(cmd);
104}
105
106Mgr::RotateAction::RotateAction(const Command::Pointer &cmd): Action(cmd)
107{
108 debugs(16, 5, HERE);
109}
110
111void
112Mgr::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
123Mgr::OfflineToggleAction::Pointer
124Mgr::OfflineToggleAction::Create(const Command::Pointer &cmd)
125{
126 return new OfflineToggleAction(cmd);
127}
128
129Mgr::OfflineToggleAction::OfflineToggleAction(const Command::Pointer &cmd):
d9fc6862 130 Action(cmd)
8822ebee
AR
131{
132 debugs(16, 5, HERE);
133}
134
135void
136Mgr::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
145void
146Mgr::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}