WIP: documenting
[src/app-framework-main.git] / docs / 1-afm-daemons.md
1 # The application framework
2
3 ## Introduction
4
5 The daemon ***afm-system-daemon*** handle applications life.
6 Understand that they will manage operations that mainly are:
7
8 - ***installation***
9 - ***uninstallation***
10 - ***running***
11 - ***terminating***
12 - ***inventory***
13
14 In addition, they ensure that operations use the security framework as needed
15 and that applications are executed in the correct context.
16
17 The daemon ***afm-system-daemon*** is accessible through AGL
18 micro-service architecture using either the binder ***afb-binder*** or
19 the client library ***libafbwsc***.
20
21 ## Starting **afm-system-daemon**
22
23 ***afm-system-daemon*** is launched by systemd services.
24 Normally, service files are located in the directory
25 */lib/systemd/system/afm-system-daemon.service*.
26
27 Internally, the daemon is built as a binding served by afb-daemon.
28
29 ## Tasks of **afm-system-daemon**
30
31 ### Maintaining list of applications
32
33 At start **afm-system-daemon** scans the directories containing
34 applications and load in memory a list of available applications
35 accessible by current user.
36
37 When **afm-system-daemon** installs or removes an application,
38 on success it sends the signal **.
39 When receiving such a signal, **afm-system-daemon** rebuilds its
40 applications list.
41
42 **afm-system-daemon** provides the data it collects about
43 applications to its clients.
44 Clients may either request the full list
45 of available applications or a more specific information about a
46 given application.
47
48 ### Launching application
49
50 **afm-system-daemon** launches application by using systemd.
51 Systemd builds a secure environment for the application
52 before starting it.
53
54 Once launched, running instances of application receive
55 a runid that identify them. On previous versions, the *runid*
56 had a special meaning. The current version uses the linux *PID*
57 of the launched process as *runid*.
58
59 ### Managing instances of running applications
60
61 **afm-system-daemon** manages the list of applications
62 that it launched.
63
64 When owning the right permissions, a client can get the list
65 of running instances and details about a specific
66 running instance.
67 It can also terminate a given application.
68
69 ### Installing and uninstalling applications
70
71 If the client own the right permissions,
72 **afm-system-daemon** delegates that task
73 to **afm-system-daemon**.
74
75 ## Using ***afm-util***
76
77 The command line tool ***afm-util*** is available in devel mode.
78
79 It uses afb-client-demo to send orders to **afm-system-daemon**.
80 This small scripts allows to send command to ***afm-system-daemon*** either
81 interactively at shell prompt or scriptically.
82
83 The syntax is simple:
84
85 - it accept a command and when requires attached arguments.
86
87 Here is the summary of ***afm-util***:
88
89 - **afm-util runnables      **:
90   list the runnable widgets installed
91
92 - **afm-util install    wgt **:
93   install the wgt file
94
95 - **afm-util uninstall  id  **:
96   remove the installed widget of id
97
98 - **afm-util detail     id  **:
99   print detail about the installed widget of id
100
101 - **afm-util runners        **:
102   list the running instance
103
104 - **afm-util start      id  **:
105   start an instance of the widget of id
106
107 - **afm-util once      id  **:
108   run once an instance of the widget of id
109
110 - **afm-util terminate  rid **:
111   terminate the running instance rid
112
113 - **afm-util state      rid **:
114   get status of the running instance rid
115
116 Here is how to list applications using ***afm-util***:
117
118 ```bash
119     afm-util runnables
120 ```
121
122 [afm-daemons]: pictures/afm-daemons.svg