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

Delete job pid if such process doesn't exist #230

Merged
merged 3 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ gem 'paypal'
gem 'parslet'
gem 'pg'
gem 'rclconf'
gem 'rmagick'
gem 'rmagick', '4.2.4'
gem 'racc'
gem 'rack'
gem 'rackup'
Expand Down
6 changes: 2 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ GEM
paypal (2.0.0)
money (> 0.0.0)
pg (1.4.5)
pkg-config (1.5.5)
public_suffix (4.0.7)
racc (1.7.1)
rack (2.2.6.4)
Expand All @@ -146,8 +145,7 @@ GEM
rclconf (1.0.0)
regexp_parser (2.2.0)
rexml (3.2.5)
rmagick (5.3.0)
pkg-config (~> 1.4)
rmagick (4.2.4)
rspec (3.10.0)
rspec-core (~> 3.10.0)
rspec-expectations (~> 3.10.0)
Expand Down Expand Up @@ -322,7 +320,7 @@ DEPENDENCIES
rake
rbs
rclconf
rmagick
rmagick (= 4.2.4)
rspec
rspec-core
rss
Expand Down
15 changes: 12 additions & 3 deletions src/util/job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,18 @@ def Job.running_job
values =[]
end
if values.length == 3
keys = [:pid, :basename, :time]
array = [keys, values].transpose.flatten
@running_job = Hash[*array]
pid = values[0]
puts "Found pid #{pid} in job.pid"
if (Process.getpgid(pid.to_i) rescue nil)
process = Process.getpgid(pid.to_i) rescue nil
puts "Job #{process} is running"
keys = [:pid, :basename, :time]
array = [keys, values].transpose.flatten
@running_job = Hash[*array]
else
puts "Job is not running, deleting staled pid file"
File.unlink(PID_FILE)
end
end
end
@running_job
Expand Down