Skip to content

Commit

Permalink
CLI and message updates
Browse files Browse the repository at this point in the history
  • Loading branch information
boazsegev committed Feb 2, 2025
1 parent 37dc0e2 commit 4abfde0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
21 changes: 13 additions & 8 deletions exe/iodine
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ module Iodine
fn = ::Iodine::Base::NeoRackUp.iodine___detect_filename
listener = Iodine.listen(nil, Iodine::Base::NeoRackUp::NOOPHandler)
root_pid = Process.pid
### TODO: Warmup
if Iodine::Base::CLI['-warmup']
### hot code reloading?
if Iodine::Base::CLI['-preload']
iodine___load_config(listener, fn, root_pid)
else
Iodine.on_state(:on_start) do
Expand All @@ -125,11 +125,6 @@ module Iodine
end
end

### Load configuration file
if Iodine::Base::CLI['--config']
p Iodine::Base::CLI['--config']
require Iodine::Base::CLI['--config']
end
### .pid file
if Iodine::Base::CLI['-pid']
pid_filename = Iodine::Base::CLI['-pid']
Expand All @@ -146,7 +141,17 @@ if Iodine::Base::CLI['-pid']
File.delete(pid_filename)
end
end

### hot restarts
if Iodine::Base::CLI['-hr'] && Iodine::Base::CLI['-w'].to_i != 0
Iodine.run_after(Iodine::Base::CLI['-hr'] * 1000, -1) do
Iodine.master? ? Process.kill("USR1", Process.pid) : false
end
end
### Load configuration file
if Iodine::Base::CLI['--config']
require Iodine::Base::CLI['--config']
end
### Start
Iodine::Base::NeoRackUp.iodine___start


5 changes: 5 additions & 0 deletions ext/iodine/iodine.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ facil.io

#include "fio-stl.h"

#ifndef DEBUG
/* Ruby doesn't always free everything pre-cleanup, so no point in counting */
#undef FIO_LEAK_COUNTER
#define FIO_LEAK_COUNTER 0
#endif
/* *****************************************************************************
Deferring Ruby Blocks
***************************************************************************** */
Expand Down
16 changes: 12 additions & 4 deletions ext/iodine/iodine_cli.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,23 @@ static VALUE iodine_cli_parse(VALUE self, VALUE required) {
"--redis -r an optional Redis URL server address. Default: none."),
FIO_CLI_INT("--redis-ping -rp Redis ping interval in seconds."),

FIO_CLI_PRINT_HEADER("Hot Application Swapping / Restarts"),
FIO_CLI_PRINT_LINE(
"(requires cluster mode, app code runs only in workers)"),
FIO_CLI_INT(
"--hot-restart -hr restarts all worker processes every n seconds."),
FIO_CLI_STRING("--config -C configuration file to be loaded."),
FIO_CLI_PRINT("NOTE: the code in the --config file won't be updated."),
FIO_CLI_BOOL("--preload -preload loads the app code before forking "
"(cluster only)."),
FIO_CLI_PRINT(
"NOTE: otherwise only the --config file will run in root process."),

FIO_CLI_PRINT_HEADER("Misc"),
FIO_CLI_BOOL("--verbose -V -d print out debugging messages."),
FIO_CLI_BOOL("--rack -R -rack prefer Rack::Builder over NeoRack."),
FIO_CLI_STRING("--config -C configuration file to be loaded."),
FIO_CLI_STRING(
"--pid -pidfile -pid name for the pid file to be created."),
FIO_CLI_BOOL(/* TODO! fixme? shouldn't preload be the default? */
"--preload -warmup warm up the application. CAREFUL! with "
"workers."),
FIO_CLI_BOOL(
"--contained attempts to handle possible container restrictions."),
FIO_CLI_PRINT(
Expand Down

0 comments on commit 4abfde0

Please sign in to comment.