]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/mgr/BasicActions.cc
2 * Copyright (C) 1996-2022 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
9 /* DEBUG: section 16 Cache Manager API */
12 #include "base/TextException.h"
13 #include "CacheManager.h"
14 #include "mgr/ActionCreator.h"
15 #include "mgr/ActionProfile.h"
16 #include "mgr/BasicActions.h"
17 #include "mgr/Registration.h"
19 #include "SquidConfig.h"
22 Mgr::IndexAction::Pointer
23 Mgr::IndexAction::Create(const Command::Pointer
&cmd
)
25 return new IndexAction(cmd
);
28 Mgr::IndexAction::IndexAction(const Command::Pointer
&aCmd
): Action(aCmd
)
30 debugs(16, 5, MYNAME
);
34 Mgr::IndexAction::dump(StoreEntry
*)
36 debugs(16, 5, MYNAME
);
39 Mgr::MenuAction::Pointer
40 Mgr::MenuAction::Create(const Command::Pointer
&cmd
)
42 return new MenuAction(cmd
);
45 Mgr::MenuAction::MenuAction(const Command::Pointer
&aCmd
): Action(aCmd
)
47 debugs(16, 5, MYNAME
);
51 Mgr::MenuAction::dump(StoreEntry
* entry
)
53 debugs(16, 5, MYNAME
);
54 Must(entry
!= nullptr);
56 typedef CacheManager::Menu::const_iterator Iterator
;
57 const CacheManager::Menu
& menu
= CacheManager::GetInstance()->menu();
59 for (Iterator a
= menu
.begin(); a
!= menu
.end(); ++a
) {
60 storeAppendPrintf(entry
, " %-22s\t%-32s\t%s\n",
61 (*a
)->name
, (*a
)->desc
,
62 CacheManager::GetInstance()->ActionProtection(*a
));
66 Mgr::ShutdownAction::Pointer
67 Mgr::ShutdownAction::Create(const Command::Pointer
&cmd
)
69 return new ShutdownAction(cmd
);
72 Mgr::ShutdownAction::ShutdownAction(const Command::Pointer
&aCmd
): Action(aCmd
)
74 debugs(16, 5, MYNAME
);
78 Mgr::ShutdownAction::dump(StoreEntry
*)
80 debugs(16, DBG_CRITICAL
, "Shutdown by Cache Manager command.");
84 Mgr::ReconfigureAction::Pointer
85 Mgr::ReconfigureAction::Create(const Command::Pointer
&cmd
)
87 return new ReconfigureAction(cmd
);
90 Mgr::ReconfigureAction::ReconfigureAction(const Command::Pointer
&aCmd
):
93 debugs(16, 5, MYNAME
);
97 Mgr::ReconfigureAction::dump(StoreEntry
* entry
)
99 debugs(16, DBG_IMPORTANT
, "Reconfigure by Cache Manager command.");
100 storeAppendPrintf(entry
, "Reconfiguring Squid Process ....");
104 Mgr::RotateAction::Pointer
105 Mgr::RotateAction::Create(const Command::Pointer
&cmd
)
107 return new RotateAction(cmd
);
110 Mgr::RotateAction::RotateAction(const Command::Pointer
&aCmd
): Action(aCmd
)
112 debugs(16, 5, MYNAME
);
116 Mgr::RotateAction::dump(StoreEntry
* entry
)
118 debugs(16, DBG_IMPORTANT
, "Rotate Logs by Cache Manager command.");
119 storeAppendPrintf(entry
, "Rotating Squid Process Logs ....");
120 #if defined(_SQUID_LINUX_THREADS_)
121 rotate_logs(SIGQUIT
);
123 rotate_logs(SIGUSR1
);
127 Mgr::OfflineToggleAction::Pointer
128 Mgr::OfflineToggleAction::Create(const Command::Pointer
&cmd
)
130 return new OfflineToggleAction(cmd
);
133 Mgr::OfflineToggleAction::OfflineToggleAction(const Command::Pointer
&aCmd
):
136 debugs(16, 5, MYNAME
);
140 Mgr::OfflineToggleAction::dump(StoreEntry
* entry
)
142 Config
.onoff
.offline
= !Config
.onoff
.offline
;
143 debugs(16, DBG_IMPORTANT
, "offline_mode now " << (Config
.onoff
.offline
? "ON" : "OFF") << " by Cache Manager request.");
145 storeAppendPrintf(entry
, "offline_mode is now %s\n",
146 Config
.onoff
.offline
? "ON" : "OFF");
150 Mgr::RegisterBasics()
152 RegisterAction("index", "Cache Manager Interface", &Mgr::IndexAction::Create
, 0, 1);
153 RegisterAction("menu", "Cache Manager Menu", &Mgr::MenuAction::Create
, 0, 1);
154 RegisterAction("offline_toggle", "Toggle offline_mode setting", &Mgr::OfflineToggleAction::Create
, 1, 1);
155 RegisterAction("shutdown", "Shut Down the Squid Process", &Mgr::ShutdownAction::Create
, 1, 1);
156 RegisterAction("reconfigure", "Reconfigure Squid", &Mgr::ReconfigureAction::Create
, 1, 1);
157 RegisterAction("rotate", "Rotate Squid Logs", &Mgr::RotateAction::Create
, 1, 1);