-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwthd.rb
More file actions
38 lines (35 loc) · 780 Bytes
/
Copy pathwthd.rb
File metadata and controls
38 lines (35 loc) · 780 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#! /usr/bin/ruby
#
# Author: BeRogue01
# Date: 12/2021
#
# Love everybody,but never sell your sword. ~ Paulo Coelho
#
# Only support on machines with fork
#
# ruby ./wthd.rb cmd [-- --conf <filename>] (maybe works...?!?!?)
#
# Commands:
# start
# stop
# restart
# status
#
require 'os'
require 'daemons'
if OS.windows? #&& ARGV[0] == 'start'
warn("This does not work right in windows. Please just run .\\wth.rb")
exit
end
pwd = Dir.pwd
Daemons.run_proc('wth.rb') do
Dir.chdir(pwd)
exec "ruby ./wth.rb"
end
# TODO: Windoze will have to be done with spawn + fork emulation...?
#Process.setproctitle("zzzzzz")
#if $options.daemonize && app.os.windows?
# f = spawn('ruby', "wth.rb") #, :out=>'NUL:', :err=>'NUL:')
# Process.detach(f)
# Process.wait(f)
# exit