Skip to content
This repository has been archived by the owner on Jun 25, 2018. It is now read-only.

cant able to stop ebooks if running in backgroud #145

Open
navinspm opened this issue Sep 18, 2017 · 1 comment
Open

cant able to stop ebooks if running in backgroud #145

navinspm opened this issue Sep 18, 2017 · 1 comment

Comments

@navinspm
Copy link

I am running ebooks in production server, using

ebooks start &

But If I am killing the pid, ebooks starts new process automatically. I cant able to kill the process completely.

@tristangrimaux
Copy link

tristangrimaux commented Sep 18, 2017

As a better way, I use daemons.py. After installing it using gem install daemons, you can use a special file to launch it
ebook.rb
#!/usr/bin/ruby2.3
#
# This file was generated by RubyGems.
#
# The application 'twitter_ebooks' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'rubygems'

version = ">= 0.a"

if ARGV.first
str = ARGV.first
str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
if str =~ /\A_(.*)_\z/ and Gem::Version.correct?($1) then
version = $1
ARGV.shift
end
end
system("pwd")
Dir.chdir "/usr/local/lib/mybot_ebooks"
system("pwd")
load Gem.bin_path('twitter_ebooks', 'ebooks', version)

ebooks_daemon.rb
# this is ebooks_daemon.rb
require 'daemons'
Daemons.run('ebook.rb')

To invoke that daemon then
ruby ebooks_daemon.rb run -- start mybot_ebooks

To stop it
ruby ebooks_daemon.rb stop

to get a status
ruby ebooks_daemon.rb status

The double dash after the command run is a way to pass parameters to the program ebook.rb

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

No branches or pull requests

2 participants