]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/mgr/BasicActions.cc
4 * DEBUG: section 16 Cache Manager API
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"
18 Mgr::MenuAction::Pointer
19 Mgr::MenuAction::Create(const Command::Pointer
&cmd
)
21 return new MenuAction(cmd
);
24 Mgr::MenuAction::MenuAction(const Command::Pointer
&cmd
): Action(cmd
)
30 Mgr::MenuAction::dump(StoreEntry
* entry
)
35 typedef CacheManager::Menu::const_iterator Iterator
;
36 const CacheManager::Menu
& menu
= CacheManager::GetInstance()->menu();
38 for (Iterator a
= menu
.begin(); a
!= menu
.end(); ++a
) {
39 storeAppendPrintf(entry
, " %-22s\t%-32s\t%s\n",
40 (*a
)->name
, (*a
)->desc
,
41 CacheManager::GetInstance()->ActionProtection(*a
));
45 Mgr::ShutdownAction::Pointer
46 Mgr::ShutdownAction::Create(const Command::Pointer
&cmd
)
48 return new ShutdownAction(cmd
);
51 Mgr::ShutdownAction::ShutdownAction(const Command::Pointer
&cmd
): Action(cmd
)
57 Mgr::ShutdownAction::dump(StoreEntry
* entry
)
59 debugs(16, DBG_CRITICAL
, "Shutdown by Cache Manager command.");
63 Mgr::ReconfigureAction::Pointer
64 Mgr::ReconfigureAction::Create(const Command::Pointer
&cmd
)
66 return new ReconfigureAction(cmd
);
69 Mgr::ReconfigureAction::ReconfigureAction(const Command::Pointer
&cmd
):
76 Mgr::ReconfigureAction::dump(StoreEntry
* entry
)
78 debugs(16, DBG_IMPORTANT
, "Reconfigure by Cache Manager command.");
79 storeAppendPrintf(entry
, "Reconfiguring Squid Process ....");
83 Mgr::RotateAction::Pointer
84 Mgr::RotateAction::Create(const Command::Pointer
&cmd
)
86 return new RotateAction(cmd
);
89 Mgr::RotateAction::RotateAction(const Command::Pointer
&cmd
): Action(cmd
)
95 Mgr::RotateAction::dump(StoreEntry
* entry
)
97 debugs(16, DBG_IMPORTANT
, "Rotate Logs by Cache Manager command.");
98 storeAppendPrintf(entry
, "Rotating Squid Process Logs ....");
99 #if defined(_SQUID_LINUX_THREADS_)
100 rotate_logs(SIGQUIT
);
102 rotate_logs(SIGUSR1
);
106 Mgr::OfflineToggleAction::Pointer
107 Mgr::OfflineToggleAction::Create(const Command::Pointer
&cmd
)
109 return new OfflineToggleAction(cmd
);
112 Mgr::OfflineToggleAction::OfflineToggleAction(const Command::Pointer
&cmd
):
119 Mgr::OfflineToggleAction::dump(StoreEntry
* entry
)
121 Config
.onoff
.offline
= !Config
.onoff
.offline
;
122 debugs(16, DBG_IMPORTANT
, "offline_mode now " << (Config
.onoff
.offline
? "ON" : "OFF") << " by Cache Manager request.");
124 storeAppendPrintf(entry
, "offline_mode is now %s\n",
125 Config
.onoff
.offline
? "ON" : "OFF");
129 Mgr::RegisterBasics()
131 RegisterAction("offline_toggle", "Toggle offline_mode setting", &Mgr::OfflineToggleAction::Create
, 1, 1);
132 RegisterAction("shutdown", "Shut Down the Squid Process", &Mgr::ShutdownAction::Create
, 1, 1);
133 RegisterAction("reconfigure", "Reconfigure Squid", &Mgr::ReconfigureAction::Create
, 1, 1);
134 RegisterAction("rotate", "Rotate Squid Logs", &Mgr::RotateAction::Create
, 1, 1);
135 RegisterAction("menu", "Cache Manager Menu", &Mgr::MenuAction::Create
, 0, 1);