Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Iodine stops on TERM signal with error when it run with -pid key and more than one worker #142

Open
zblsv opened this issue May 11, 2023 · 1 comment

Comments

@zblsv
Copy link

zblsv commented May 11, 2023

System Information

  • OS: [x86_64-linux]
  • Ruby: [3.2.2]
  • Version: [0.7.55]
  • OpenSSL: [OpenSSL 1.1.1d 10 Sep 2019]

And

  • Rack: [rack (3.0.7), rackup (2.1.0)]

Description

Iodine stops on TERM signal with error ERROR: Iodine caught an unprotected exception - Errno::ENOENT: No such file or directory when it run with -pid key and more than one worker. With one worker only it exits without errors.

Rack App to Reproduce

Can be serving static files only.

iodine -w 2 -www ./www -pid ~/iodine.pid

Testing code

kill -TERM $(tr -d '[[:space:]]' < ~/iodine.pid)

Expected behavior

Iodine shutdown without embarrassment.

Actual behavior

/home/censored/.rvm/gems/ruby-3.2.2@censored/gems/iodine-0.7.55/lib/iodine/iodine.so: warning: undefining the allocator of T_DATA class IodineObjectStorage
WARNING: Ruby application not found - missing config.ru.
         Running only static file service.
INFO: Listening on port 3000
INFO: Serving static files from ./www
INFO: Starting up Iodine:
 * Iodine 0.7.55
 * Ruby 3.2.2
 * facil.io 0.7.4 (epoll)
 * 2 Workers X 1 Threads per worker.
 * Maximum 4080 open files / sockets per worker.
 * Master (root) process: 3230.

INFO: Server is running 2 workers X 1 thread with facil.io 0.7.4 (epoll)
* Linked to OpenSSL 1.1.1d  10 Sep 2019
* Detected capacity: 4080 open file limit
* Root pid: 3230
* Press ^C to stop

INFO: 3235 is running.
INFO: 3238 is running.
INFO: Server Detected exit signal.
INFO: (3235) detected exit signal.
INFO: (3238) detected exit signal.
ERROR: Iodine caught an unprotected exception - Errno::ENOENT: No such file or directory @ apply2files - /home/censored/iodine.pid
/home/censored/.rvm/gems/ruby-3.2.2@censored/gems/iodine-0.7.55/lib/iodine.rb:205:in `delete'
/home/censored/.rvm/gems/ruby-3.2.2@censored/gems/iodine-0.7.55/lib/iodine.rb:205:in `block in <top (required)>'
ERROR:

ERROR: Iodine caught an unprotected exception - Errno::ENOENT: No such file or directory @ apply2files - /home/censored/iodine.pid
/home/censored/.rvm/gems/ruby-3.2.2@censored/gems/iodine-0.7.55/lib/iodine.rb:205:in `delete'
/home/censored/.rvm/gems/ruby-3.2.2@censored/gems/iodine-0.7.55/lib/iodine.rb:205:in `block in <top (required)>'
/home/censored/.rvm/gems/ruby-3.2.2@censored/gems/iodine-0.7.55/lib/rack/handler/iodine.rb:13:in `start'
/home/censored/.rvm/gems/ruby-3.2.2@censored/gems/iodine-0.7.55/lib/rack/handler/iodine.rb:13:in `run'
/home/censored/.rvm/gems/ruby-3.2.2@censored/gems/iodine-0.7.55/exe/iodine:274:in `call'
/home/censored/.rvm/gems/ruby-3.2.2@censored/gems/iodine-0.7.55/exe/iodine:280:in `<top (required)>'
/home/censored/.rvm/gems/ruby-3.2.2@censored/bin/iodine:25:in `load'
/home/censored/.rvm/gems/ruby-3.2.2@censored/bin/iodine:25:in `<main>'
/home/censored/.rvm/gems/ruby-3.2.2@censored/bin/ruby_executable_hooks:22:in `eval'
/home/censored/.rvm/gems/ruby-3.2.2@censored/bin/ruby_executable_hooks:22:in `<main>'
	from /home/censored/.rvm/gems/ruby-3.2.2@censored/bin/ruby_executable_hooks:22:in `<main>'
	from /home/censored/.rvm/gems/ruby-3.2.2@censored/bin/ruby_executable_hooks:22:in `eval'
	from /home/censored/.rvm/gems/ruby-3.2.2@censored/bin/iodine:25:in `<main>'
	from /home/censored/.rvm/gems/ruby-3.2.2@censored/bin/iodine:25:in `load'
	from /home/censored/.rvm/gems/ruby-3.2.2@censored/gems/iodine-0.7.55/exe/iodine:280:in `<top (required)>'
	from /home/censored/.rvm/gems/ruby-3.2.2@censored/gems/iodine-0.7.55/exe/iodine:274:in `call'
	from /home/censored/.rvm/gems/ruby-3.2.2@censored/gems/iodine-0.7.55/lib/rack/handler/iodine.rb:13:in `run'
	from /home/censored/.rvm/gems/ruby-3.2.2@censored/gems/iodine-0.7.55/lib/rack/handler/iodine.rb:13:in `start'
ERROR:

INFO:    ---  Shutdown Complete  ---

INFO: (3235) cleanup complete.
INFO: (3238) cleanup complete.


@zblsv
Copy link
Author

zblsv commented May 15, 2023

As I can see in the code (lib/iodine.rb:205), the master and all the workers are trying to delete the pidfile. File.delete raises exception on file absence. This can be fixed by allowing only master to delete pidfile (with Iodine.master? check).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant