]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/mgr/BasicActions.cc
2 * DEBUG: section 16 Cache Manager API
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"
16 Mgr::IndexAction::Pointer
17 Mgr::IndexAction::Create(const Command::Pointer
&cmd
)
19 return new IndexAction(cmd
);
22 Mgr::IndexAction::IndexAction(const Command::Pointer
&cmd
): Action(cmd
)
28 Mgr::IndexAction::dump(StoreEntry
* entry
)
33 Mgr::MenuAction::Pointer
34 Mgr::MenuAction::Create(const Command::Pointer
&cmd
)
36 return new MenuAction(cmd
);
39 Mgr::MenuAction::MenuAction(const Command::Pointer
&cmd
): Action(cmd
)
45 Mgr::MenuAction::dump(StoreEntry
* entry
)
50 typedef CacheManager::Menu::const_iterator Iterator
;
51 const CacheManager::Menu
& menu
= CacheManager::GetInstance()->menu();
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
));
60 Mgr::ShutdownAction::Pointer
61 Mgr::ShutdownAction::Create(const Command::Pointer
&cmd
)
63 return new ShutdownAction(cmd
);
66 Mgr::ShutdownAction::ShutdownAction(const Command::Pointer
&cmd
): Action(cmd
)
72 Mgr::ShutdownAction::dump(StoreEntry
* entry
)
74 debugs(16, DBG_CRITICAL
, "Shutdown by Cache Manager command.");
78 Mgr::ReconfigureAction::Pointer
79 Mgr::ReconfigureAction::Create(const Command::Pointer
&cmd
)
81 return new ReconfigureAction(cmd
);
84 Mgr::ReconfigureAction::ReconfigureAction(const Command::Pointer
&cmd
):
91 Mgr::ReconfigureAction::dump(StoreEntry
* entry
)
93 debugs(16, DBG_IMPORTANT
, "Reconfigure by Cache Manager command.");
94 storeAppendPrintf(entry
, "Reconfiguring Squid Process ....");
98 Mgr::RotateAction::Pointer
99 Mgr::RotateAction::Create(const Command::Pointer
&cmd
)
101 return new RotateAction(cmd
);
104 Mgr::RotateAction::RotateAction(const Command::Pointer
&cmd
): Action(cmd
)
110 Mgr::RotateAction::dump(StoreEntry
* entry
)
112 debugs(16, DBG_IMPORTANT
, "Rotate Logs by Cache Manager command.");
113 storeAppendPrintf(entry
, "Rotating Squid Process Logs ....");
114 #if defined(_SQUID_LINUX_THREADS_)
115 rotate_logs(SIGQUIT
);
117 rotate_logs(SIGUSR1
);
121 Mgr::OfflineToggleAction::Pointer
122 Mgr::OfflineToggleAction::Create(const Command::Pointer
&cmd
)
124 return new OfflineToggleAction(cmd
);
127 Mgr::OfflineToggleAction::OfflineToggleAction(const Command::Pointer
&cmd
):
134 Mgr::OfflineToggleAction::dump(StoreEntry
* entry
)
136 Config
.onoff
.offline
= !Config
.onoff
.offline
;
137 debugs(16, DBG_IMPORTANT
, "offline_mode now " << (Config
.onoff
.offline
? "ON" : "OFF") << " by Cache Manager request.");
139 storeAppendPrintf(entry
, "offline_mode is now %s\n",
140 Config
.onoff
.offline
? "ON" : "OFF");
144 Mgr::RegisterBasics()
146 RegisterAction("index", "Cache Manager Interface", &Mgr::IndexAction::Create
, 0, 1);
147 RegisterAction("menu", "Cache Manager Menu", &Mgr::MenuAction::Create
, 0, 1);
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);