Copyright | (c) Alexey Radkov 2018-2023 |
---|---|
License | BSD-style |
Maintainer | alexey.radkov@gmail.com |
Stability | stable |
Portability | non-portable (requires POSIX) |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Synopsis
- terminateWorkerProcess :: String -> IO a
- restartWorkerProcess :: String -> IO a
- finalizeHTTPRequest :: Int -> Maybe String -> IO a
- workerProcessIsExiting :: SomeException -> Bool
- ngxRequestPtr :: ByteString -> Ptr ()
- ngxNow :: IO CTime
- ngxPid :: IO CPid
Various functions to access low-level Nginx API
Various functions to access low-level Nginx API, mostly wrappers around corresponding functions and data from module NgxExport.
Exported functions
terminateWorkerProcess :: String -> IO a Source #
Terminates the Nginx worker process from a Haskell service.
Nginx master process shall not spawn a new worker process thereafter. This
function throws exception TerminateWorkerProcess
, and therefore terminates
the worker process effectively only from a Haskell service.
restartWorkerProcess :: String -> IO a Source #
Restarts the Nginx worker process from a Haskell service.
Nginx master process shall spawn a new worker process after termination of
the current one. This function throws exception RestartWorkerProcess
, and
therefore terminates the worker process effectively only from a Haskell
service.
finalizeHTTPRequest :: Int -> Maybe String -> IO a Source #
Finalizes the current HTTP request from a Haskell asynchronous variable handler.
This function throws exception FinalizeHTTPRequest
, and therefore
terminates the HTTP request effectively only from a Haskell asynchronous
variable handler.
workerProcessIsExiting :: SomeException -> Bool Source #
Checks that a generic exception is of type WorkerProcessIsExiting
.
This can be useful to check quickly in an exception handler whether a Haskell service has been interrupted because the worker process is exiting.
ngxRequestPtr :: ByteString -> Ptr () Source #
Unmarshals the value of Nginx variable $_r_ptr into a pointer to the Nginx request object.
This is safe to use in request-based Haskell handlers such as synchronous and asynchronous tasks and content handlers, but not in services and their derivatives. In asynchronous tasks and content handlers the value must be used as read-only. The value can be passed into a C plugin, however, as opposed to usual functions in Nginx C code, it must be tested against the NULL value.
Returns the current time as the number of seconds elapsed since the UNIX epoch.
The value is taken from Nginx core, so no additional system calls get
involved. On the other hand, it means that this is only safe to use from
an Nginx worker's main thread, i.e. in synchronous Haskell handlers and
service hooks. Be also aware that this is a small type casting hack:
the value is interpreted as being of type time_t
while having been
actually wrapped in a bigger C struct as its first element.