BasicActions.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
3  *
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.
7  */
8 
9 /* DEBUG: section 16 Cache Manager API */
10 
11 #include "squid.h"
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"
18 #include "protos.h"
19 #include "SquidConfig.h"
20 #include "Store.h"
21 
24 {
25  return new IndexAction(cmd);
26 }
27 
29 {
30  debugs(16, 5, HERE);
31 }
32 
33 void
35 {
36  debugs(16, 5, HERE);
37 }
38 
41 {
42  return new MenuAction(cmd);
43 }
44 
46 {
47  debugs(16, 5, HERE);
48 }
49 
50 void
52 {
53  debugs(16, 5, HERE);
54  Must(entry != NULL);
55 
56  typedef CacheManager::Menu::const_iterator Iterator;
58 
59  for (Iterator a = menu.begin(); a != menu.end(); ++a) {
60  storeAppendPrintf(entry, " %-22s\t%-32s\t%s\n",
61  (*a)->name, (*a)->desc,
63  }
64 }
65 
68 {
69  return new ShutdownAction(cmd);
70 }
71 
73 {
74  debugs(16, 5, HERE);
75 }
76 
77 void
79 {
80  debugs(16, DBG_CRITICAL, "Shutdown by Cache Manager command.");
81  shut_down(SIGTERM);
82 }
83 
86 {
87  return new ReconfigureAction(cmd);
88 }
89 
91  Action(aCmd)
92 {
93  debugs(16, 5, HERE);
94 }
95 
96 void
98 {
99  debugs(16, DBG_IMPORTANT, "Reconfigure by Cache Manager command.");
100  storeAppendPrintf(entry, "Reconfiguring Squid Process ....");
101  reconfigure(SIGHUP);
102 }
103 
106 {
107  return new RotateAction(cmd);
108 }
109 
111 {
112  debugs(16, 5, HERE);
113 }
114 
115 void
117 {
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);
122 #else
123  rotate_logs(SIGUSR1);
124 #endif
125 }
126 
129 {
130  return new OfflineToggleAction(cmd);
131 }
132 
134  Action(aCmd)
135 {
136  debugs(16, 5, HERE);
137 }
138 
139 void
141 {
143  debugs(16, DBG_IMPORTANT, "offline_mode now " << (Config.onoff.offline ? "ON" : "OFF") << " by Cache Manager request.");
144 
145  storeAppendPrintf(entry, "offline_mode is now %s\n",
146  Config.onoff.offline ? "ON" : "OFF");
147 }
148 
149 void
151 {
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);
158 }
159 
returns available Cache Manager actions and their access requirements
Definition: BasicActions.h:38
static Pointer Create(const CommandPointer &cmd)
Definition: BasicActions.cc:23
virtual void dump(StoreEntry *entry)
Definition: BasicActions.cc:51
static MemPoolIterator Iterator
Definition: Pool.cc:26
void rotate_logs(int sig)
Definition: main.cc:721
static Pointer Create(const CommandPointer &cmd)
Definition: BasicActions.cc:40
void storeAppendPrintf(StoreEntry *e, const char *fmt,...)
Definition: store.cc:872
virtual void dump(StoreEntry *entry)
Definition: BasicActions.cc:97
virtual void dump(StoreEntry *entry)
const CommandPointer cmd
the command that caused this action
Definition: Action.h:86
shuts Squid down
Definition: BasicActions.h:50
static Pointer Create(const CommandPointer &cmd)
Definition: BasicActions.cc:67
#define DBG_CRITICAL
Definition: Debug.h:40
static CacheManager * GetInstance()
#define DBG_IMPORTANT
Definition: Debug.h:41
changes offline mode
Definition: BasicActions.h:86
const char * ActionProtection(const Mgr::ActionProfilePointer &profile)
ShutdownAction(const CommandPointer &cmd)
Definition: BasicActions.cc:72
virtual void dump(StoreEntry *entry)
#define NULL
Definition: types.h:166
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Debug.h:123
void RegisterBasics()
Registers profiles for the actions above; TODO: move elsewhere?
std::ostream & HERE(std::ostream &s)
Definition: Debug.h:152
const Menu & menu() const
Definition: CacheManager.h:45
reconfigures Squid
Definition: BasicActions.h:62
OfflineToggleAction(const CommandPointer &cmd)
static Pointer Create(const CommandPointer &cmd)
void reconfigure(int sig)
Definition: main.cc:735
static Pointer Create(const CommandPointer &cmd)
Definition: BasicActions.cc:85
starts log rotation
Definition: BasicActions.h:74
IndexAction(const CommandPointer &cmd)
Definition: BasicActions.cc:28
RotateAction(const CommandPointer &cmd)
struct SquidConfig::@111 onoff
static Pointer Create(const CommandPointer &cmd)
virtual void dump(StoreEntry *entry)
Definition: BasicActions.cc:78
#define Must(condition)
Like assert() but throws an exception instead of aborting the process.
Definition: TextException.h:73
std::vector< Mgr::ActionProfilePointer > Menu
Definition: CacheManager.h:34
ReconfigureAction(const CommandPointer &cmd)
Definition: BasicActions.cc:90
void RegisterAction(char const *action, char const *desc, OBJH *handler, int pw_req_flag, int atomic)
Definition: Registration.cc:16
virtual void dump(StoreEntry *entry)
Definition: BasicActions.cc:34
MenuAction(const CommandPointer &cmd)
Definition: BasicActions.cc:45
class SquidConfig Config
Definition: SquidConfig.cc:12
void shut_down(int sig)
Definition: main.cc:776

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors