File: run_with_server.cf.sub

package info (click to toggle)
cfengine3 3.24.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 37,552 kB
  • sloc: ansic: 163,161; sh: 10,296; python: 2,950; makefile: 1,744; lex: 784; yacc: 633; perl: 211; pascal: 157; xml: 21; sed: 13
file content (110 lines) | stat: -rw-r--r-- 3,089 bytes parent folder | download | duplicates (3)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
body classes if_failed(x)
{
      repair_failed => { "$(x)" };
}

body contain run_under_shell
{
      useshell => "useshell";
}

body action in_background
{
      background => "true";
}


bundle agent start_server(server_config)
{
  classes:
      "debug_server" expression => "debug_mode";

  vars:
      "config_basename" string => filestat("$(server_config)", basename);
      "dlog"            string => "$(sys.workdir)/server-debug.$(config_basename).log";

  commands:
    !debug_server.!windows::
      "$(sys.cf_serverd) -Kf $(server_config)"
        classes => if_failed("server_failed");
    !debug_server.windows::
      # Windows cannot daemonize and needs to start in background.
      "$(sys.cf_serverd) -Kf $(server_config)"
        action => in_background,
        classes => if_failed("server_failed");

    debug_server::
      "$(sys.cf_serverd) -Kldf $(server_config) > $(dlog) 2>&1"
        contain => run_under_shell,
        action => in_background,
        classes => if_failed("server_failed");

    debug_server|windows::
      # Sleep 3 seconds since cf-serverd takes some time to start in background
      # mode. We need to add a handle with $(server_config) in it so that the
      # promise is not skipped if this bundle is used for multiple configs.
      "$(G.sleep) 3"
        contain => run_under_shell,
        handle => "sleep_for_$(server_config)";

  reports:
    debug_server::
      "$(sys.cf_serverd) was run in debug mode, the logs will be in $(dlog)";
}


bundle agent run_test(test_name)
{
  classes:
      "debug_client" expression => "debug_mode";

  vars:
      "dlog" string => "$(sys.workdir)/agent-debug.log";

  commands:
    !debug_client::
      "$(sys.cf_agent) -KIf $(test_name) -D DEBUG,AUTO 2>&1 | $(G.tee) $(dlog)"
        contain => run_under_shell;
    debug_client::
      "$(sys.cf_agent) -Kldf $(test_name) -D DEBUG,EXTRA,AUTO 2>&1 | $(G.tee) $(dlog)"
        contain => run_under_shell;

  reports:
    debug_client::
      "$(sys.cf_agent) was run in debug mode, the logs will be in $(dlog)";
}


bundle agent run_runagent(runagent_params)
{
  classes:
      "debug_client" expression => "debug_mode";

  vars:
      "dlog" string => "$(sys.workdir)/runagent-debug.log";

  commands:
    !debug_client::
      "$(sys.cf_runagent) -I $(runagent_params) 2>&1 | $(G.tee) $(dlog)"
        contain => run_under_shell;
    debug_client::
      "$(sys.cf_runagent) -d $(runagent_params) 2>&1 | $(G.tee) $(dlog)"
        contain => run_under_shell;

  reports:
    debug_client::
      "$(sys.cf_runagent) was run in debug mode, the logs will be in $(dlog)";
}


bundle agent stop_server(server_config)
{
  # On some old platforms, "ps" truncates its output, which CFEngine depends on. This can lead to
  # the test servers not being killed.
  # On HP-UX you can set the DEFAULT_CMD_LINE_WIDTH inside /etc/default/ps to a higher value, which
  # controls the maximum line length of "ps". Unfortunately it is not overridable from the
  # environment.
  processes:
      "$(server_config)"
        signals => { "term", "kill" };
}