Re: [systemd-devel] [PATCH v4] run: introduce timer support option

2014-12-04 Thread WaLyong Cho
On 12/04/2014 03:44 AM, Lennart Poettering wrote:
> On Tue, 02.12.14 23:35, WaLyong Cho (walyong@samsung.com) wrote:
> 
>> Supported timer options --on-active=, --on-boot=, --on-startup=,
>> --on-unit-active=, --on-unit-inactive=, --on-calendar=. Each options
>> corresponding with OnActiveSec=, OnBootSec=, OnStartupSec=,
>> OnUnitActiveSec=, OnUnitInactiveSec= of timer respectively.
> 
> I think a nice way to make both the properties of the service and of
> the timer unit configurable would be to introduce --timer-property= in
> addition to --property= as parameter. --property= would then always be
> applied to the service/scope being created, and --timer-property=
> would apply to the timer unit instead. Do we need the tables of the
> 3rd patch which a simple scheme like that?

I replied on 3rd patch email. If we don't need 3rd patch then I will
change it to --timer-property=.

WaLyong
> 
> Lennart
> 
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH v4] run: introduce timer support option

2014-12-03 Thread Lennart Poettering
On Tue, 02.12.14 23:35, WaLyong Cho (walyong@samsung.com) wrote:

> Supported timer options --on-active=, --on-boot=, --on-startup=,
> --on-unit-active=, --on-unit-inactive=, --on-calendar=. Each options
> corresponding with OnActiveSec=, OnBootSec=, OnStartupSec=,
> OnUnitActiveSec=, OnUnitInactiveSec= of timer respectively.

I think a nice way to make both the properties of the service and of
the timer unit configurable would be to introduce --timer-property= in
addition to --property= as parameter. --property= would then always be
applied to the service/scope being created, and --timer-property=
would apply to the timer unit instead. Do we need the tables of the
3rd patch which a simple scheme like that?

Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH v4] run: introduce timer support option

2014-12-02 Thread WaLyong Cho
Supported timer options --on-active=, --on-boot=, --on-startup=,
--on-unit-active=, --on-unit-inactive=, --on-calendar=. Each options
corresponding with OnActiveSec=, OnBootSec=, OnStartupSec=,
OnUnitActiveSec=, OnUnitInactiveSec= of timer respectively.
---
 man/systemd-run.xml  |  42 +++
 src/libsystemd/sd-bus/bus-util.c |  14 +-
 src/run/run.c| 581 ---
 3 files changed, 538 insertions(+), 99 deletions(-)

diff --git a/man/systemd-run.xml b/man/systemd-run.xml
index 28a9878..abac26c 100644
--- a/man/systemd-run.xml
+++ b/man/systemd-run.xml
@@ -210,6 +210,37 @@ along with systemd; If not, see 
.
   
   
 
+  
+--on-active=
+--on-boot=
+--on-startup=
+--on-unit-active=
+--on-unit-inactive=
+
+Defines monotonic timers relative to different
+starting points. Also see OnActiveSec=,
+OnBootSec=,
+OnStartupSec=,
+OnUnitActiveSec= and
+OnUnitInactiveSec= in
+
systemd.timer5.
 This
+option has no effect in conjunction with
+--scope.
+
+  
+
+  
+--on-calendar=
+
+Defines realtime (i.e. wallclock) timers with
+calendar event expressions. Also see
+OnCalendar= in
+
systemd.timer5.
 This
+option has no effect in conjunction with
+--scope.
+
+  
+
   
   
 
@@ -250,6 +281,16 @@ Sep 08 07:37:21 bupkis env[19948]: 
BOOT_IMAGE=/vmlinuz-3.11.0-0.rc5.git6.2.fc20.
 property.
 
 # systemd-run -p BlockIOWeight=10 updatedb
+
+The following command will touch a file after 10 seconds.
+
+# date; systemd-run --on-active=10 touch /tmp/hello
+Mon Oct 27 20:02:57 KST 2014
+Running as unit run-66.timer.
+# journalctl -u run-115.service
+-- Logs begin at Mon 2014-10-27 19:44:57 KST, end at Mon 2014-10-27 20:03:15 
KST. --
+Oct 27 20:03:15 container systemd[1]: Starting /bin/touch /tmp/hello...
+Oct 27 20:03:15 container systemd[1]: Started /bin/touch 
/tmp/hello.
   
 
   
@@ -263,6 +304,7 @@ Sep 08 07:37:21 bupkis env[19948]: 
BOOT_IMAGE=/vmlinuz-3.11.0-0.rc5.git6.2.fc20.
   
systemd.slice5,
   
systemd.exec5,
   
systemd.resource-control5,
+  
systemd.timer5,
   
machinectl1
 
   
diff --git a/src/libsystemd/sd-bus/bus-util.c b/src/libsystemd/sd-bus/bus-util.c
index bdaa449..0f1a89c 100644
--- a/src/libsystemd/sd-bus/bus-util.c
+++ b/src/libsystemd/sd-bus/bus-util.c
@@ -1372,7 +1372,8 @@ int bus_append_unit_property_assignment(sd_bus_message 
*m, const char *assignmen
 
 if (STR_IN_SET(field,
"CPUAccounting", "MemoryAccounting", 
"BlockIOAccounting",
-   "SendSIGHUP", "SendSIGKILL")) {
+   "SendSIGHUP", "SendSIGKILL",
+   "WakeSystem")) {
 
 r = parse_boolean(eq);
 if (r < 0) {
@@ -1533,6 +1534,17 @@ int bus_append_unit_property_assignment(sd_bus_message 
*m, const char *assignmen
 
 r = sd_bus_message_append(m, "v", "i", sig);
 
+} else if (streq(field, "AccuracySec")) {
+usec_t u;
+
+r = parse_sec(eq, &u);
+if (r < 0) {
+log_error("Failed to parse %s value %s", field, eq);
+return -EINVAL;
+}
+
+r = sd_bus_message_append(m, "v", "t", u);
+
 } else {
 log_error("Unknown assignment %s.", assignment);
 return -EINVAL;
diff --git a/src/run/run.c b/src/run/run.c
index 85eb052..e1ef7b4 100644
--- a/src/run/run.c
+++ b/src/run/run.c
@@ -30,6 +30,7 @@
 #include "env-util.h"
 #include "path-util.h"
 #include "bus-error.h"
+#include "calendarspec.h"
 
 static bool arg_scope = false;
 static bool arg_remain_after_exit = false;
@@ -47,10 +48,19 @@ static int arg_nice = 0;
 static bool arg_nice_set = false;
 static char **arg_environment = NULL;
 static char **arg_property = NULL;
+static bool with_timer = false;
+static usec_t arg_on_active = 0;
+static usec_t arg_on_boot = 0;
+static usec_t arg_on_startup = 0;
+static usec_t arg_on_unit_active = 0;
+static usec_t arg_on_unit_inactive = 0;
+static char *arg_on_calendar = NULL;
 
 static void help(void) {
-printf("%s [OPTIONS...] COMMAND [ARGS...]\n\n"
-   "Run the specified command in a transient scope or service 
unit.\n\n"
+printf("%s [OPTIONS...] [COMMAND] [ARGS...]\n\n"
+   "Run the specified command in a transient scope or service or 
timer\n"
+   "unit. If timer option is specified and unit is exist which 
is\n"
+   "specified with --unit option then command can be ommited.\n\n"
"  -h --help Show this help\n"
" --version  Show package version\n"
" --user Run as us