<feed xmlns='http://www.w3.org/2005/Atom'>
<title>unit.git/src/ruby, branch gzip-v37</title>
<subtitle>Universal Web Application Server</subtitle>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/'/>
<entry>
<title>Ruby: used nxt_ruby_exception_log() in nxt_ruby_rack_init().</title>
<updated>2022-10-04T18:33:11+00:00</updated>
<author>
<name>Andrew Clayton</name>
<email>a.clayton@nginx.com</email>
</author>
<published>2022-10-03T12:01:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=d806a90609e99cb4c8db71d620d5db3d26e83693'/>
<id>d806a90609e99cb4c8db71d620d5db3d26e83693</id>
<content type='text'>
For consistency use nxt_ruby_exception_log() rather than nxt_alert() in
nxt_ruby_rack_init().

Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
For consistency use nxt_ruby_exception_log() rather than nxt_alert() in
nxt_ruby_rack_init().

Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Ruby: added support for rack V3.</title>
<updated>2022-10-04T18:33:11+00:00</updated>
<author>
<name>Zhidao HONG</name>
<email>z.hong@f5.com</email>
</author>
<published>2022-09-28T14:51:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=dc9f592d6e7123d57924146dcbf1be80366bc98b'/>
<id>dc9f592d6e7123d57924146dcbf1be80366bc98b</id>
<content type='text'>
Ruby applications would fail to start if they were using rack v3

  2022/09/28 15:48:46 [alert] 0#80912 [unit] Ruby: Failed to parse rack script
  2022/09/28 15:48:46 [notice] 80911#80911 app process 80912 exited with code 1

This was due to a change in the rack API

Rack V2

  def self.load_file(path, opts = Server::Options.new)
    ...
    cfgfile.sub!(/^__END__\n.*\Z/m, '')
    app = new_from_string cfgfile, path

    return app, options
  end

Rack V3

  def self.load_file(path)
    ...

    return new_from_string(config, path)
  end

This patch handles _both_ the above APIs by correctly handling the cases
where we do and don't get an array returned from
nxt_ruby_rack_parse_script().

Closes: &lt;https://github.com/nginx/unit/issues/755&gt;
Tested-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
Reviewed-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
[ Andrew: Patch by Zhidao, commit message by me with input from Zhidao ]
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Ruby applications would fail to start if they were using rack v3

  2022/09/28 15:48:46 [alert] 0#80912 [unit] Ruby: Failed to parse rack script
  2022/09/28 15:48:46 [notice] 80911#80911 app process 80912 exited with code 1

This was due to a change in the rack API

Rack V2

  def self.load_file(path, opts = Server::Options.new)
    ...
    cfgfile.sub!(/^__END__\n.*\Z/m, '')
    app = new_from_string cfgfile, path

    return app, options
  end

Rack V3

  def self.load_file(path)
    ...

    return new_from_string(config, path)
  end

This patch handles _both_ the above APIs by correctly handling the cases
where we do and don't get an array returned from
nxt_ruby_rack_parse_script().

Closes: &lt;https://github.com/nginx/unit/issues/755&gt;
Tested-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
Reviewed-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
[ Andrew: Patch by Zhidao, commit message by me with input from Zhidao ]
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Renamed a couple of members of nxt_unit_request_t.</title>
<updated>2022-10-03T13:32:28+00:00</updated>
<author>
<name>Andrew Clayton</name>
<email>a.clayton@nginx.com</email>
</author>
<published>2022-09-29T19:59:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=b00983369be5f356280168b4c5d600bd7d614c60'/>
<id>b00983369be5f356280168b4c5d600bd7d614c60</id>
<content type='text'>
This is a preparatory patch that renames the 'local' and 'local_length'
members of the nxt_unit_request_t structure to 'local_addr' and
'local_addr_length' in preparation for the adding of 'local_port' and
'local_port_length' members.

Suggested-by: Zhidao HONG &lt;z.hong@f5.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This is a preparatory patch that renames the 'local' and 'local_length'
members of the nxt_unit_request_t structure to 'local_addr' and
'local_addr_length' in preparation for the adding of 'local_port' and
'local_port_length' members.

Suggested-by: Zhidao HONG &lt;z.hong@f5.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Ruby: prevented a segfault on receiving SIGINT (^C).</title>
<updated>2022-08-31T12:17:02+00:00</updated>
<author>
<name>Andrew Clayton</name>
<email>a.clayton@f5.com</email>
</author>
<published>2022-08-31T11:49:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=b26624fc10cc1f4eb88c16ac8fb5b6b4b61895fc'/>
<id>b26624fc10cc1f4eb88c16ac8fb5b6b4b61895fc</id>
<content type='text'>
As was reported[0] by @travisbell on GitHub, if running unit from the
terminal in the foreground when hitting ^C to exit it, the ruby
application processes would segfault if they were using threads.

It's not 100% clear where the actual problem lies, but it _looks_ like
it may be in ruby.

The simplest way to deal with this for now is to just ignore SIGINT in
the ruby application processes. Unit will still receive and handle it,
cleanly shutting everything down.

For people who want to handle SIGINT in their ruby application running
under unit they can still trap SIGINT and it will override the ignore.

[0]: https://github.com/nginx/unit/issues/562#issuecomment-1223229585

Closes: https://github.com/nginx/unit/issues/562
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
As was reported[0] by @travisbell on GitHub, if running unit from the
terminal in the foreground when hitting ^C to exit it, the ruby
application processes would segfault if they were using threads.

It's not 100% clear where the actual problem lies, but it _looks_ like
it may be in ruby.

The simplest way to deal with this for now is to just ignore SIGINT in
the ruby application processes. Unit will still receive and handle it,
cleanly shutting everything down.

For people who want to handle SIGINT in their ruby application running
under unit they can still trap SIGINT and it will override the ignore.

[0]: https://github.com/nginx/unit/issues/562#issuecomment-1223229585

Closes: https://github.com/nginx/unit/issues/562
</pre>
</div>
</content>
</entry>
<entry>
<title>Ruby: fixed segfault on SIGTERM signal.</title>
<updated>2022-07-28T03:00:15+00:00</updated>
<author>
<name>Zhidao HONG</name>
<email>z.hong@f5.com</email>
</author>
<published>2022-07-28T03:00:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=2bd4a455278dbce756c1dc8be07515f73d611e3b'/>
<id>2bd4a455278dbce756c1dc8be07515f73d611e3b</id>
<content type='text'>
This closes #562 issue on GitHub.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This closes #562 issue on GitHub.
</pre>
</div>
</content>
</entry>
<entry>
<title>Ruby: fixed contents of SCRIPT_NAME.</title>
<updated>2022-07-27T10:46:42+00:00</updated>
<author>
<name>Alejandro Colomar</name>
<email>alx.manpages@gmail.com</email>
</author>
<published>2022-06-09T12:39:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=9b4b4925b38333b8d7795331d27db9811f43d72a'/>
<id>9b4b4925b38333b8d7795331d27db9811f43d72a</id>
<content type='text'>
Having the basename of the script pathname was incorrect.  While
we don't have something more accurate, the best thing to do is to
have it empty (which should be the right thing most of the time).

This closes #715 issue on GitHub.

The bug was introduced in git commit
0032543fa65f454c471c968998190b027c1ff270
'Ruby: added the Rack environment parameter "SCRIPT_NAME".'.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Having the basename of the script pathname was incorrect.  While
we don't have something more accurate, the best thing to do is to
have it empty (which should be the right thing most of the time).

This closes #715 issue on GitHub.

The bug was introduced in git commit
0032543fa65f454c471c968998190b027c1ff270
'Ruby: added the Rack environment parameter "SCRIPT_NAME".'.
</pre>
</div>
</content>
</entry>
<entry>
<title>Ruby: added stream IO "close" required by Rack specification.</title>
<updated>2022-05-13T11:33:40+00:00</updated>
<author>
<name>Zhidao HONG</name>
<email>z.hong@f5.com</email>
</author>
<published>2022-05-13T11:33:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=5883a2670fbeb1610014ec122a5fd20312399a90'/>
<id>5883a2670fbeb1610014ec122a5fd20312399a90</id>
<content type='text'>
This closes #654 issue on Github.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This closes #654 issue on Github.
</pre>
</div>
</content>
</entry>
<entry>
<title>Ruby: added the Rack environment parameter "SCRIPT_NAME".</title>
<updated>2022-03-09T05:29:43+00:00</updated>
<author>
<name>Zhidao HONG</name>
<email>z.hong@f5.com</email>
</author>
<published>2022-03-09T05:29:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=0032543fa65f454c471c968998190b027c1ff270'/>
<id>0032543fa65f454c471c968998190b027c1ff270</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Moving request limit control to libunit.</title>
<updated>2021-10-28T14:46:54+00:00</updated>
<author>
<name>Max Romanov</name>
<email>max.romanov@nginx.com</email>
</author>
<published>2021-10-28T14:46:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=bba97134e983541e94cf73e93900729e3a3e61fc'/>
<id>bba97134e983541e94cf73e93900729e3a3e61fc</id>
<content type='text'>
Introducting application graceful stop.  For now only used when application
process reach request limit value.

This closes #585 issue on GitHub.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Introducting application graceful stop.  For now only used when application
process reach request limit value.

This closes #585 issue on GitHub.
</pre>
</div>
</content>
</entry>
<entry>
<title>Ruby: process and thread lifecycle hooks.</title>
<updated>2021-07-02T12:57:55+00:00</updated>
<author>
<name>Oisin Canty</name>
<email>o.canty@f5.com</email>
</author>
<published>2021-07-02T12:57:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=655e321075c0beebe14eba83deeac1ba4c9e0b29'/>
<id>655e321075c0beebe14eba83deeac1ba4c9e0b29</id>
<content type='text'>
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.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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.
</pre>
</div>
</content>
</entry>
</feed>
