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