Skip to content

Commit

Permalink
service: add umask(2) configuration parameter (#29)
Browse files Browse the repository at this point in the history
Github Issue: #29

Umask(2) configuration parameter for daemon is added from riser 0.1.12.
  • Loading branch information
y10k committed Nov 15, 2019
1 parent a61fc62 commit ea5f6d9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/rims/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def load(config, load_path=nil)
# daemon:
# daemonize: true
# debug: false
# umask: 0037
# status_file: rims.pid
# server_polling_interval_seconds: 3
# server_privileged_user: nobody
Expand Down Expand Up @@ -418,6 +419,10 @@ def daemon_debug?
end
end

def daemon_umask
@config.dig('daemon', 'umask') || 0037
end

def status_file
file_path = @config.dig('daemon', 'status_file') || 'rims.pid'
file_path = Pathname(file_path)
Expand Down
8 changes: 8 additions & 0 deletions test/test_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,14 @@ def test_daemon_debug?(data)
assert_equal(expected_value, @c.daemon_debug?)
end

data('default' => [ 0037, {} ],
'umask' => [ 0022, { daemon: { umask: 0022 } } ])
def test_daemon_umask(data)
expected_value, config = data
@c.load(config)
assert_equal(expected_value, @c.daemon_umask)
end

data('default' => [ File.join(BASE_DIR, 'rims.pid'), {} ],
'rel_path' => [ File.join(BASE_DIR, 'status'), { daemon: { status_file: 'status' } } ],
'abs_path' => [ '/var/run/rims.pid', { daemon: { status_file: '/var/run/rims.pid' } } ])
Expand Down

0 comments on commit ea5f6d9

Please # to comment.