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