summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_application.h
diff options
context:
space:
mode:
authorOisin Canty <o.canty@f5.com>2021-07-02 12:57:55 +0000
committerOisin Canty <o.canty@f5.com>2021-07-02 12:57:55 +0000
commit655e321075c0beebe14eba83deeac1ba4c9e0b29 (patch)
treecb3fb16282bd571e6636f19e77199518264fdadd /src/nxt_application.h
parent7d2bc04e391f9216fb4e0464cb43c9c438f7e034 (diff)
downloadunit-655e321075c0beebe14eba83deeac1ba4c9e0b29.tar.gz
unit-655e321075c0beebe14eba83deeac1ba4c9e0b29.tar.bz2
Ruby: process and thread lifecycle hooks.
This feature allows one to specify blocks of code that are called when certain lifecycle events occur. A user configures a "hooks" property on the app configuration that points to a script. This script will be evaluated on boot and should contain blocks of code that will be called on specific events. An example of configuration: { "type": "ruby", "processes": 2, "threads": 2, "user": "vagrant", "group": "vagrant", "script": "config.ru", "hooks": "hooks.rb", "working_directory": "/home/vagrant/unit/rbhooks", "environment": { "GEM_HOME": "/home/vagrant/.ruby" } } An example of a valid "hooks.rb" file follows: File.write("./hooks.#{Process.pid}", "hooks evaluated") on_worker_boot do File.write("./worker_boot.#{Process.pid}", "worker booted") end on_thread_boot do File.write("./thread_boot.#{Process.pid}.#{Thread.current.object_id}", "thread booted") end on_thread_shutdown do File.write("./thread_shutdown.#{Process.pid}.#{Thread.current.object_id}", "thread shutdown") end on_worker_shutdown do File.write("./worker_shutdown.#{Process.pid}", "worker shutdown") end This closes issue #535 on GitHub.
Diffstat (limited to 'src/nxt_application.h')
-rw-r--r--src/nxt_application.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/nxt_application.h b/src/nxt_application.h
index 45e7fa48..6fbdc4be 100644
--- a/src/nxt_application.h
+++ b/src/nxt_application.h
@@ -74,6 +74,7 @@ typedef struct {
typedef struct {
nxt_str_t script;
uint32_t threads;
+ nxt_str_t hooks;
} nxt_ruby_app_conf_t;