Process Worker¶
Functions for controlling forking and signal handling in yimmo-wsgi
-
YMO_WSGI_TKILL_TIMEOUT¶
HACK: move elsewhere
#define YMO_WSGI_TKILL_TIMEOUT 5.0
Types¶
-
struct ymo_wsgi_proc¶
Stores process information for the WSGI server in both single- and multi-processing mode.
struct ymo_wsgi_proc { /* Process Info: */ char* proc_name; size_t proc_name_len; size_t proc_name_buflen; long no_wsgi_proc; long no_wsgi_threads; int restart_count; long port; int term; /* Process Type: */ int is_main; int is_worker; /* Main process: */ pid_t* children; ev_signal sigint_watcher; ev_signal sigchld_watcher; ev_signal sigterm_watcher; ev_timer pkill_timer; ev_timer tkill_timer; /* Child process: */ pid_t ppid; int worker_id; ymo_wsgi_worker_t* w_threads; /* All processes: */ ymo_server_t* http_srv; struct ev_loop* loop; char* module; char* app; ymo_yaml_doc_t* cfg; };
Functions¶
-
pid_t ymo_wsgi_proc_fork_new(ymo_wsgi_proc_t *w_proc, int worker_id)¶
Invoked by the main process in multi-processing mode to spawn a new worker process.
-
int ymo_wsgi_proc_main(ymo_wsgi_proc_t *w_proc)¶
Entrypoint for WSGI worker processes (or the main process in single-proc mode).
-
void ymo_wsgi_proc_sigint(struct ev_loop *loop, ev_signal *w, int revents)¶
SIGINT handler.
-
void ymo_wsgi_proc_sigchld(struct ev_loop *loop, ev_signal *w, int revents)¶
SIGCHLD handler.
-
void ymo_wsgi_proc_sigterm(struct ev_loop *loop, ev_signal *w, int revents)¶
SIGTERM handler.
-
ymo_wsgi_worker_t *ymo_wsgi_init_workers(int no_wsgi_threads, struct ev_loop *loop)¶
Spawn
no_wsgi_threads
worker threads.Returns a pointer to an array of works.
Warning
This is a HACK.
-
ymo_status_t ymo_wsgi_stop_workers(int no_wsgi_threads, ymo_wsgi_worker_t *workers)¶
Stop the WSGI worker threads in the the
workers
array.Warning
This is a HACK.
-
ymo_wsgi_worker_t *ymo_wsgi_proc_assign_worker(ymo_wsgi_proc_t *w_proc, size_t session_id)¶
Given a session ID, return the worker that should handle requests from the session.