Skip to content

Commit

Permalink
Remove the daemonize feature
Browse files Browse the repository at this point in the history
Fixes #359.

Puma 6 no longer supports the --daemonize option.

It is not something we wish to support inside Gemstash.
  • Loading branch information
th1agoalmeida authored and olleolleolle committed Oct 8, 2023
1 parent 2635c7a commit 07474ff
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 62 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## Unreleased

- Fix uninitialized constant error when using Redis cache ([#375](https://github.com/rubygems/gemstash/pull/375), [@ chris72205](https://github.com/ chris72205))
- Remove --daemonize option, no longer supported by Puma.

## 2.6.0 (2023-09-30)

Expand Down
3 changes: 0 additions & 3 deletions docs/gemstash-configuration.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,3 @@ placed in the [base path](docs/gemstash-configuration.5.md#base-path).
## Valid values

Any valid file name, or `:stdout` to log to `$stdout`

*Note: Using `:stdout` for the `:log_file` requires [running with
`--no-daemonize`](docs/gemstash-start.1.md#options).*
8 changes: 3 additions & 5 deletions docs/gemstash-debugging.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ might want to start by looking at the server log. You can find the log
at `server.log` within your base directory. By default, this will be at
`~/.gemstash/server.log`.

You might find it easier to view the log directly in your terminal. If
you run Gemstash [in non-daemonized
form](docs/gemstash-start.1.md#options), the log will be output directly to
standard out:
You might find it easier to view the log directly in your terminal.
Gemstash outputs its log directly to standard out:

$ gemstash start --no-daemonize
$ gemstash start

You can also [check the status](docs/gemstash-status.1.md) of the server:

Expand Down
2 changes: 1 addition & 1 deletion docs/gemstash-multiple-sources.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ end
And run the Gemstash with the credentials set in an ENV variable:

``` bash
GEMSTASH_MY__GEM___SOURCE__LOCAL=user:password gemstash start --no-daemonize --config-file config.yml.erb
GEMSTASH_MY__GEM___SOURCE__LOCAL=user:password gemstash start --config-file config.yml.erb
```

The name of the ENV variable is the uppercase version of the host name,
Expand Down
6 changes: 1 addition & 5 deletions docs/gemstash-start.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ gemstash-start - Starts the Gemstash server

# Synopsis

`gemstash start [--no-daemonize] [--config-file FILE]`
`gemstash start [--config-file FILE]`

# Description

Expand All @@ -19,7 +19,3 @@ Starts the Gemstash server.
using the default config file at `~/.gemstash/config.yml` or
[`~/.gemstash/config.yml.erb`](docs/gemstash-customize.7.md#erb-parsed-config),
then you must specify the config file via this option.

- `--no-daemonize`: The Gemstash server daemonizes itself by default.
Provide this option to instead run the server until `Ctrl-C` is typed.
When not daemonized, the log will be output to standard out.
2 changes: 0 additions & 2 deletions lib/gemstash/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ def setup
end

desc "start", "Starts your gemstash server"
method_option :daemonize, :type => :boolean, :default => true, :desc =>
"Daemonize the server"
method_option :config_file, :type => :string, :desc =>
"Config file to load when starting"
def start
Expand Down
22 changes: 2 additions & 20 deletions lib/gemstash/cli/start.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,46 +11,28 @@ class Start < Gemstash::CLI::Base
def run
prepare
setup_logging
store_daemonized
@cli.say("Starting gemstash!", :green)
Puma::CLI.new(args, Gemstash::Logging::StreamLogger.puma_events).run
end

private

def setup_logging
return unless daemonize?

# Enables logging at all times, perhaps there needs to be a new option for this?
Gemstash::Logging.setup_logger(gemstash_env.log_file)
end

def store_daemonized
Gemstash::Env.daemonized = daemonize?
end

def daemonize?
@cli.options[:daemonize]
end

def puma_config
File.expand_path("../puma.rb", __dir__)
end

def args
config_args + pidfile_args + daemonize_args
config_args + pidfile_args
end

def config_args
["--config", puma_config]
end

def daemonize_args
if daemonize?
["--daemon"]
else
[]
end
end
end
end
end
11 changes: 0 additions & 11 deletions lib/gemstash/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,6 @@ def self.current=(value)
Thread.current[:gemstash_env] = value
end

def self.daemonized?
raise "Daemonized hasn't been set yet!" if @daemonized.nil?

@daemonized
end

def self.daemonized=(value)
value = false if value.nil?
@daemonized = value
end

def config
@config ||= Gemstash::Configuration.new
end
Expand Down
3 changes: 0 additions & 3 deletions man/gemstash-configuration.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,8 @@ the [base path][BASE_PATH].

Any valid file name, or `:stdout` to log to `$stdout`

*Note: Using `:stdout` for the `:log_file` requires [running with `--no-daemonize`][NO_DAEMONIZE].*

[SETUP]: ./gemstash-setup.1.md
[SEQUEL]: http://sequel.jeremyevans.net/
[SEQUEL_CONNECT]: http://sequel.jeremyevans.net/rdoc/files/doc/opening_databases_rdoc.html#label-General+connection+options
[PUMA_BINDING]: https://github.com/puma/puma#binding-tcp--sockets
[BASE_PATH]: ./gemstash-configuration.5.md#base-path
[NO_DAEMONIZE]: ./gemstash-start.1.md#options
8 changes: 4 additions & 4 deletions man/gemstash-debugging.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ to start by looking at the server log. You can find the log at `server.log`
within your base directory. By default, this will be at
`~/.gemstash/server.log`.

You might find it easier to view the log directly in your terminal. If you run
Gemstash [in non-daemonized form][START_OPTIONS], the log will be
output directly to standard out:
You might find it easier to view the log directly in your terminal. Gemstash
outputs its log directly to standard out:

```
$ gemstash start --no-daemonize
$ gemstash start
```

You can also [check the status][STATUS] of the server:
Expand Down
4 changes: 2 additions & 2 deletions man/gemstash-multiple-sources.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ end
And run the Gemstash with the credentials set in an ENV variable:

```bash
GEMSTASH_MY__GEM___SOURCE__LOCAL=user:password gemstash start --no-daemonize --config-file config.yml.erb
GEMSTASH_MY__GEM___SOURCE__LOCAL=user:password gemstash start --config-file config.yml.erb
```

The name of the ENV variable is the uppercase version of the host name,
with all `.` characters replaced with `__`, all `-` with `___` and a `GEMSTASH_` prefix
with all `.` characters replaced with `__`, all `-` with `___` and a `GEMSTASH_` prefix
(it uses the same syntax as [Bundler](https://bundler.io/v2.4/man/bundle-config.1.html#CREDENTIALS-FOR-GEM-SOURCES)).

Example: `my.gem-source.local` => `GEMSTASH_MY__GEM___SOURCE__LOCAL`
Expand Down
7 changes: 1 addition & 6 deletions man/gemstash-start.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ gemstash-start - Starts the Gemstash server

# Synopsis

`gemstash start [--no-daemonize] [--config-file FILE]`
`gemstash start [--config-file FILE]`

# Description

Expand All @@ -23,9 +23,4 @@ Starts the Gemstash server.
at `~/.gemstash/config.yml` or [`~/.gemstash/config.yml.erb`][ERB_CONFIG],
then you must specify the config file via this option.

* `--no-daemonize`:
The Gemstash server daemonizes itself by default. Provide this option to instead
run the server until `Ctrl-C` is typed. When not daemonized, the log will be
output to standard out.

[ERB_CONFIG]: ./gemstash-customize.7.md#erb-parsed-config

0 comments on commit 07474ff

Please sign in to comment.