Cutelyst  3.4.0
server.h
1 /*
2  * Copyright (C) 2016-2021 Daniel Nicoletti <dantti12@gmail.com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 #ifndef CUTELYSTSERVER_H
19 #define CUTELYSTSERVER_H
20 
21 #include <QObject>
22 
23 #include <Cutelyst/cutelyst_global.h>
24 
25 class QCoreApplication;
26 
27 namespace Cutelyst {
28 
29 class Application;
30 class ServerPrivate;
35 class CUTELYST_SERVER_EXPORT Server : public QObject
36 {
37  Q_OBJECT
38  Q_DECLARE_PRIVATE(Server)
39 public:
40  explicit Server(QObject *parent = nullptr);
41  virtual ~Server();
42 
43  void parseCommandLine(const QStringList &args);
44 
61  int exec(Cutelyst::Application *app = nullptr);
62 
75  bool start(Cutelyst::Application *app = nullptr);
76 
81  void stop();
82 
88  Q_PROPERTY(QString application READ application WRITE setApplication NOTIFY changed)
89  void setApplication(const QString &application);
90  QString application() const;
91 
96  Q_PROPERTY(QString threads READ threads WRITE setThreads NOTIFY changed)
97  void setThreads(const QString &threads);
98  QString threads() const;
99 
105  Q_PROPERTY(QString processes READ processes WRITE setProcesses NOTIFY changed)
106  void setProcesses(const QString &process);
107  QString processes() const;
108 
113  Q_PROPERTY(QString chdir READ chdir WRITE setChdir NOTIFY changed)
114  void setChdir(const QString &chdir);
115  QString chdir() const;
116 
121  Q_PROPERTY(QStringList http_socket READ httpSocket WRITE setHttpSocket NOTIFY changed)
122  void setHttpSocket(const QStringList &httpSocket);
123  QStringList httpSocket() const;
124 
129  Q_PROPERTY(QStringList http2_socket READ http2Socket WRITE setHttp2Socket NOTIFY changed)
130  void setHttp2Socket(const QStringList &http2Socket);
131  QStringList http2Socket() const;
132 
137  Q_PROPERTY(quint32 http2_header_table_size READ http2HeaderTableSize WRITE setHttp2HeaderTableSize NOTIFY changed)
138  void setHttp2HeaderTableSize(quint32 headerTableSize);
139  quint32 http2HeaderTableSize() const;
140 
146  Q_PROPERTY(bool upgrade_h2c READ upgradeH2c WRITE setUpgradeH2c NOTIFY changed)
147  void setUpgradeH2c(bool enable);
148  bool upgradeH2c() const;
149 
155  Q_PROPERTY(bool https_h2 READ httpsH2 WRITE setHttpsH2 NOTIFY changed)
156  void setHttpsH2(bool enable);
157  bool httpsH2() const;
158 
163  Q_PROPERTY(QStringList https_socket READ httpsSocket WRITE setHttpsSocket NOTIFY changed)
164  void setHttpsSocket(const QStringList &httpsSocket);
165  QStringList httpsSocket() const;
166 
171  Q_PROPERTY(QStringList fastcgi_socket READ fastcgiSocket WRITE setFastcgiSocket NOTIFY changed)
172  void setFastcgiSocket(const QStringList &fastcgiSocket);
173  QStringList fastcgiSocket() const;
174 
179  Q_PROPERTY(QString socket_access READ socketAccess WRITE setSocketAccess NOTIFY changed)
180  void setSocketAccess(const QString &socketAccess);
181  QString socketAccess() const;
182 
187  Q_PROPERTY(int socket_timeout READ socketTimeout WRITE setSocketTimeout NOTIFY changed)
188  void setSocketTimeout(int timeout);
189  int socketTimeout() const;
190 
195  Q_PROPERTY(QString chdir2 READ chdir2 WRITE setChdir2 NOTIFY changed)
196  void setChdir2(const QString &chdir2);
197  QString chdir2() const;
198 
203  Q_PROPERTY(QStringList ini READ ini WRITE setIni NOTIFY changed)
204  void setIni(const QStringList &files);
205  QStringList ini() const;
206 
211  Q_PROPERTY(QStringList json READ json WRITE setJson NOTIFY changed)
212  void setJson(const QStringList &files);
213  QStringList json() const;
214 
219  Q_PROPERTY(QStringList static_map READ staticMap WRITE setStaticMap NOTIFY changed)
220  void setStaticMap(const QStringList &staticMap);
221  QStringList staticMap() const;
222 
227  Q_PROPERTY(QStringList static_map2 READ staticMap2 WRITE setStaticMap2 NOTIFY changed)
228  void setStaticMap2(const QStringList &staticMap);
229  QStringList staticMap2() const;
230 
236  Q_PROPERTY(bool master READ master WRITE setMaster NOTIFY changed)
237  void setMaster(bool enable);
238  bool master() const;
239 
244  Q_PROPERTY(bool auto_reload READ autoReload WRITE setAutoReload NOTIFY changed)
245  void setAutoReload(bool enable);
246  bool autoReload() const;
247 
252  Q_PROPERTY(QStringList touch_reload READ touchReload WRITE setTouchReload NOTIFY changed)
253  void setTouchReload(const QStringList &files);
254  QStringList touchReload() const;
255 
262  Q_PROPERTY(int listen READ listenQueue WRITE setListenQueue NOTIFY changed)
263  void setListenQueue(int size);
264  int listenQueue() const;
265 
270  Q_PROPERTY(int buffer_size READ bufferSize WRITE setBufferSize NOTIFY changed)
271  void setBufferSize(int size);
272  int bufferSize() const;
273 
279  Q_PROPERTY(qint64 post_buffering READ postBuffering WRITE setPostBuffering NOTIFY changed)
280  void setPostBuffering(qint64 size);
281  qint64 postBuffering() const;
282 
287  Q_PROPERTY(qint64 post_buffering_bufsize READ postBufferingBufsize WRITE setPostBufferingBufsize NOTIFY changed)
288  void setPostBufferingBufsize(qint64 size);
289  qint64 postBufferingBufsize() const;
290 
295  Q_PROPERTY(bool tcp_nodelay READ tcpNodelay WRITE setTcpNodelay NOTIFY changed)
296  void setTcpNodelay(bool enable);
297  bool tcpNodelay() const;
298 
303  Q_PROPERTY(bool so_keepalive READ soKeepalive WRITE setSoKeepalive NOTIFY changed)
304  void setSoKeepalive(bool enable);
305  bool soKeepalive() const;
306 
311  Q_PROPERTY(int socket_sndbuf READ socketSndbuf WRITE setSocketSndbuf NOTIFY changed)
312  void setSocketSndbuf(int value);
313  int socketSndbuf() const;
314 
319  Q_PROPERTY(int socket_rcvbuf READ socketRcvbuf WRITE setSocketRcvbuf NOTIFY changed)
320  void setSocketRcvbuf(int value);
321  int socketRcvbuf() const;
322 
327  Q_PROPERTY(int websocket_max_size READ websocketMaxSize WRITE setWebsocketMaxSize NOTIFY changed)
328  void setWebsocketMaxSize(int value);
329  int websocketMaxSize() const;
330 
335  Q_PROPERTY(QString pidfile READ pidfile WRITE setPidfile NOTIFY changed)
336  void setPidfile(const QString &file);
337  QString pidfile() const;
338 
343  Q_PROPERTY(QString pidfile2 READ pidfile2 WRITE setPidfile2 NOTIFY changed)
344  void setPidfile2(const QString &file);
345  QString pidfile2() const;
346 
352  Q_PROPERTY(QString uid READ uid WRITE setUid NOTIFY changed)
353  void setUid(const QString &uid);
354  QString uid() const;
355 
361  Q_PROPERTY(QString gid READ gid WRITE setGid NOTIFY changed)
362  void setGid(const QString &gid);
363  QString gid() const;
364 
370  Q_PROPERTY(bool no_initgroups READ noInitgroups WRITE setNoInitgroups NOTIFY changed)
371  void setNoInitgroups(bool enable);
372  bool noInitgroups() const;
373 
379  Q_PROPERTY(QString chown_socket READ chownSocket WRITE setChownSocket NOTIFY changed)
380  void setChownSocket(const QString &chownSocket);
381  QString chownSocket() const;
382 
388  Q_PROPERTY(QString umask READ umask WRITE setUmask NOTIFY changed)
389  void setUmask(const QString &value);
390  QString umask() const;
391 
397  Q_PROPERTY(int cpu_affinity READ cpuAffinity WRITE setCpuAffinity NOTIFY changed)
398  void setCpuAffinity(int value);
399  int cpuAffinity() const;
400 
406  Q_PROPERTY(bool reuse_port READ reusePort WRITE setReusePort NOTIFY changed)
407  void setReusePort(bool enable);
408  bool reusePort() const;
409 
414  Q_PROPERTY(bool lazy READ lazy WRITE setLazy NOTIFY changed)
415  void setLazy(bool enable);
416  bool lazy() const;
417 
424  Q_PROPERTY(bool using_frontend_proxy READ usingFrontendProxy WRITE setUsingFrontendProxy NOTIFY changed)
425  void setUsingFrontendProxy(bool enable);
426  bool usingFrontendProxy() const;
427 
428 Q_SIGNALS:
432  void ready();
433 
437  void stopped();
438 
439  void changed();
440 
444  void errorOccured(const QString& error);
445 
446 protected:
447  ServerPrivate *d_ptr;
448 };
449 
450 }
451 
452 #endif // CUTELYSTSERVER_H
The Cutelyst Application.
Definition: application.h:56
void errorOccured(const QString &error)
bool start(Cutelyst::Application *app=nullptr)
This function will start the WSGI server in user application mode.
int exec(Cutelyst::Application *app=nullptr)
The Cutelyst namespace holds all public Cutelyst API.
Definition: Mainpage.dox:8