dyn-ruby-win32daemon 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +39 -0
  3. data/bin/dyn-daemon +63 -0
  4. metadata +109 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9865e3c62d77afeeb77227f4403b00e1affc9315
4
+ data.tar.gz: 59f745d4d7e18172d2d386cc31df64f65b78d7b9
5
+ SHA512:
6
+ metadata.gz: a090d105c804629ad0b6b95207113ca9f5f5ece176aa32c663888109f68e7c620d858792fbd3d46690461d53d8aaeaa9e82d7bea717bfdfc2c5183f00e338860
7
+ data.tar.gz: 8201263ce061291ec86be7ea25795a1b2cb99a7123070144ed2ccc720aaf8b5738ffca61351294b11909a98f617db3393b7d587fe61ba12f7af903877dc2e517
@@ -0,0 +1,39 @@
1
+ # DynTask
2
+
3
+ First of all, inspiration DynTask comes from the filewatcher project. The goal is a bit different since the goal is to provide a very basic system to manage chainable tasks.
4
+
5
+
6
+ ## Kinds of task
7
+
8
+ when depending on source (and/or output) file or content to be copied in some particular path, one may be interested in:
9
+
10
+ * local task: everything is executed inside the same computer. This allows to write task in any path different from the source file path.
11
+ * remote task: when using docker or dropbox-like tools, a synchronized task can be executed in a different computer or docker container. As a constraint, the source (and/or output) file path and the task file path have to be defined relatively to a common root independently in any synchronized computers supposed to execute the tasks. Obviously, the task file and source file can be in the same directory which is the simplest case.
12
+
13
+ The goal of such approach is to watch only one folder containing task file with predefined extension and not subdirectories which makes the watching less reactive.
14
+
15
+ ## Main actions to perform
16
+
17
+ * dyn
18
+ * dyn-cli
19
+ * pdflatex
20
+ * pandoc
21
+
22
+
23
+ ## Examples
24
+
25
+ ```{bash}
26
+ ## To specify a folder to watch with specific tasks
27
+ dyntask-init default <dyndoc-project-folder>:dyn,pandoc,dyn_cli
28
+
29
+ ## Optional for pandoc task
30
+ dyntask-init pandoc-extra dir --force /dyndoc-library/pandoc-extra
31
+ ##
32
+ dyntask-init pandoc-extra wget
33
+ ```
34
+
35
+ ## How this works
36
+
37
+ * add_task: to push task
38
+ * save_tasks: to save all the pushed tasks
39
+ * read_tasks: read first task and pop to the stack of tasks
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env ruby
2
+ require "fileutils"
3
+ SRV=ARGV[1].strip
4
+ exit unless ["dyn-srv","dyntask-srv"].include? SRV
5
+ FileUtils.mkdir_p File.join(ENV["USERPROFILE"],"dyndoc","log")
6
+ DYN_DAEMON_LOG_FILE = File.join(ENV["USERPROFILE"],"dyndoc","log","win32daemon_")+SRV+".log"
7
+ DYN_DAEMON_DIR=File.dirname `where ruby`.strip
8
+
9
+ ACTION=ARGV[2] || "status"
10
+
11
+ case ACTION
12
+ when "start"
13
+ begin
14
+ require 'win32/daemon'
15
+ include Win32
16
+
17
+ class DynDaemon < Daemon
18
+
19
+ def service_init
20
+ File.open(DYN_DAEMON_LOG_FILE, 'a'){ |f| f.puts "Initializing service #{Time.now}" }
21
+
22
+ @server_pid = Process.spawn 'dyntask-server', :chdir => DYN_DAEMON_DIR, :err => [DYN_DAEMON_LOG_FILE, 'a']
23
+ File.open(DYN_DAEMON_LOG_FILE, 'a'){ |f| f.puts @server_pid.inspect }
24
+ end
25
+
26
+ def service_main
27
+ File.open(DYN_DAEMON_LOG_FILE, 'a'){ |f| f.puts "Service is running #{Time.now} with pid #{@server_pid}" }
28
+ while running?
29
+ sleep 10
30
+ endx
31
+ end
32
+
33
+ def service_stop
34
+ File.open(DYN_DAEMON_LOG_FILE, 'a'){ |f| f.puts "Stopping server thread #{Time.now}" }
35
+ system "taskkill /PID #{@server_pid} /T /F"
36
+ Process.waitall
37
+ File.open(DYN_DAEMON_LOG_FILE, 'a'){ |f| f.puts "Service stopped #{Time.now}" }
38
+ exit!
39
+ end
40
+ end
41
+
42
+ DynDaemon.mainloop
43
+
44
+ rescue Exception => e
45
+ File.open(DYN_DAEMON_LOG_FILE,'a+'){ |f| f.puts " ***Daemon failure #{Time.now} exception=#{e.inspect}\n#{e.backtrace.join($/)}" }
46
+ raise
47
+ end
48
+ when "stop"
49
+ require 'sys/proctable'
50
+
51
+ pids = []
52
+
53
+ ProcTable.ps{ |s|
54
+ pids.push(s.pid) if s.cmdline =~ /#{SRV}/
55
+ }
56
+
57
+ p Process.kill(9,pids.last)
58
+ when "status"
59
+ require 'sys/proctable'
60
+ ProcTable.ps{ |s|
61
+ puts s.pid+"->"+s.cmdline if s.cmdline =~ /#{SRV}/
62
+ }
63
+ end
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dyn-ruby-win32daemon
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - CQLS
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-03-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: win32-service
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '0.8'
20
+ - - '>='
21
+ - !ruby/object:Gem::Version
22
+ version: 0.8.7
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '0.8'
30
+ - - '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 0.8.7
33
+ - !ruby/object:Gem::Dependency
34
+ name: win32-process
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ~>
38
+ - !ruby/object:Gem::Version
39
+ version: '0.8'
40
+ - - '>='
41
+ - !ruby/object:Gem::Version
42
+ version: 0.8.3
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ~>
48
+ - !ruby/object:Gem::Version
49
+ version: '0.8'
50
+ - - '>='
51
+ - !ruby/object:Gem::Version
52
+ version: 0.8.3
53
+ - !ruby/object:Gem::Dependency
54
+ name: sys-proctable
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ~>
58
+ - !ruby/object:Gem::Version
59
+ version: '1.0'
60
+ - - '>='
61
+ - !ruby/object:Gem::Version
62
+ version: 1.0.0
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '1.0'
70
+ - - '>='
71
+ - !ruby/object:Gem::Version
72
+ version: 1.0.0
73
+ description: |2
74
+ Managing dyn daemon.
75
+ email: rdrouilh@gmail.com
76
+ executables:
77
+ - dyn-daemon
78
+ extensions: []
79
+ extra_rdoc_files: []
80
+ files:
81
+ - bin/dyn-daemon
82
+ - README.md
83
+ homepage: http://rcqls.github.io
84
+ licenses:
85
+ - MIT
86
+ - GPL-2
87
+ metadata: {}
88
+ post_install_message:
89
+ rdoc_options: []
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ requirements:
103
+ - none
104
+ rubyforge_project:
105
+ rubygems_version: 2.0.14
106
+ signing_key:
107
+ specification_version: 4
108
+ summary: dyn-srv and dyntask daemon
109
+ test_files: []