index.html 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. <!doctype html>
  2. <!-- Generated by scripts/sitegen. Edit the files there and run `go run .`; changes made here are overwritten. -->
  3. <html lang="en" data-theme="light" class="accent-makers">
  4. <head>
  5. <meta charset="utf-8">
  6. <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
  7. <title>Subservices (deprecated) — ArozOS</title>
  8. <meta name="description" content="How ArozOS subservices work: a binary in any language that ArozOS starts, reverse-proxies and puts on the desktop. The subservice infrastructure is deprecated and no longer maintained.">
  9. <link rel="canonical" href="https://os.aroz.org/subservice/">
  10. <link rel="alternate" hreflang="en" href="https://os.aroz.org/subservice/" data-href="./">
  11. <link rel="alternate" hreflang="zh-Hant" href="https://os.aroz.org/zh-tw/subservice/" data-href="../zh-tw/subservice/">
  12. <link rel="alternate" hreflang="zh-Hans" href="https://os.aroz.org/zh-cn/subservice/" data-href="../zh-cn/subservice/">
  13. <link rel="alternate" hreflang="ja" href="https://os.aroz.org/ja/subservice/" data-href="../ja/subservice/">
  14. <link rel="alternate" hreflang="x-default" href="https://os.aroz.org/subservice/">
  15. <script>
  16. (function () {
  17. var d = document.documentElement, s = null, l = null;
  18. d.className += " js";
  19. try { s = localStorage.getItem("aroz-theme"); l = localStorage.getItem("aroz-lang"); } catch (e) {}
  20. var p = s === "light" || s === "dark" ? s : "auto";
  21. d.setAttribute("data-theme-pref", p);
  22. d.setAttribute("data-theme", p === "auto" ? (matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light") : p);
  23. if (l || d.lang !== "en" || /bot|crawl|spider/i.test(navigator.userAgent)) return;
  24. var want = "", list = navigator.languages || [navigator.language || ""];
  25. for (var i = 0; i < list.length && !want; i++) {
  26. var c = (list[i] || "").toLowerCase();
  27. if (c.indexOf("zh") === 0) want = /hant|tw|hk|mo/.test(c) ? "zh-Hant" : "zh-Hans";
  28. else if (c.indexOf("ja") === 0) want = "ja";
  29. else if (c.indexOf("en") === 0) want = "en";
  30. }
  31. try { localStorage.setItem("aroz-lang", want || "en"); } catch (e) { return; }
  32. if (!want || want === "en") return;
  33. var alt = document.querySelector('link[rel="alternate"][hreflang="' + want + '"]');
  34. if (alt) location.replace(alt.getAttribute("data-href") + location.hash);
  35. })();
  36. </script>
  37. <meta name="color-scheme" content="light dark">
  38. <meta name="theme-color" content="#ffffff" media="(prefers-color-scheme: light)">
  39. <meta name="theme-color" content="#000000" media="(prefers-color-scheme: dark)">
  40. <meta property="og:type" content="website">
  41. <meta property="og:site_name" content="ArozOS">
  42. <meta property="og:title" content="Subservices (deprecated) — ArozOS">
  43. <meta property="og:description" content="How ArozOS subservices work: a binary in any language that ArozOS starts, reverse-proxies and puts on the desktop. The subservice infrastructure is deprecated and no longer maintained.">
  44. <meta property="og:url" content="https://os.aroz.org/subservice/">
  45. <meta property="og:image" content="https://os.aroz.org/img/og.png">
  46. <meta property="og:locale" content="en_US">
  47. <meta name="twitter:card" content="summary_large_image">
  48. <link rel="icon" href="../img/favicon.png">
  49. <link rel="apple-touch-icon" href="../img/apple-touch-icon.png">
  50. <link rel="stylesheet" href="../assets/site.css?v=0b27a21e">
  51. <script src="../assets/site.js?v=0b27a21e" defer></script>
  52. </head>
  53. <body>
  54. <a class="skip" href="#main">Skip to content</a>
  55. <header class="nav" id="nav">
  56. <div class="nav-in">
  57. <a class="brand" href="../" aria-label="ArozOS"><svg class="logo" viewBox="0 0 256 256" aria-hidden="true"><rect class="logo-bg" width="256" height="256" rx="58"/><path class="logo-fg" d="M70 58h116l-58 70zM128 128l58 70H70z"/></svg><span>ArozOS</span></a>
  58. <nav class="nav-links" aria-label="Main">
  59. <a href="../desktop.html">Desktop</a>
  60. <a href="../media.html">Media</a>
  61. <a href="../office.html">Office</a>
  62. <a href="../ai.html">AI</a>
  63. <a href="../makers.html">Makers</a>
  64. <a href="../storage.html">Storage</a>
  65. <a href="../server.html">Server</a>
  66. </nav>
  67. <div class="nav-tools">
  68. <div class="pop" data-pop>
  69. <button type="button" class="icon-btn" aria-haspopup="menu" aria-expanded="false" aria-label="Language" title="Language"><svg class="i" viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="9"/><path d="M3 12h18M12 3c2.5 2.7 3.8 5.7 3.8 9s-1.3 6.3-3.8 9c-2.5-2.7-3.8-5.7-3.8-9S9.5 5.7 12 3z"/></svg></button>
  70. <div class="pop-menu" role="menu"><a role="menuitemradio" href="./" hreflang="en" lang="en" data-lang="en" aria-checked="true">English</a><a role="menuitemradio" href="../zh-tw/subservice/" hreflang="zh-Hant" lang="zh-Hant" data-lang="zh-Hant" aria-checked="false">繁體中文</a><a role="menuitemradio" href="../zh-cn/subservice/" hreflang="zh-Hans" lang="zh-Hans" data-lang="zh-Hans" aria-checked="false">简体中文</a><a role="menuitemradio" href="../ja/subservice/" hreflang="ja" lang="ja" data-lang="ja" aria-checked="false">日本語</a></div>
  71. </div>
  72. <div class="pop" data-pop>
  73. <button type="button" class="icon-btn theme-btn" aria-haspopup="menu" aria-expanded="false" aria-label="Appearance" title="Appearance"><span class="ti-light"><svg class="i" viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="4"/><path d="M12 2.5v2M12 19.5v2M5.3 5.3l1.4 1.4M17.3 17.3l1.4 1.4M2.5 12h2M19.5 12h2M5.3 18.7l1.4-1.4M17.3 6.7l1.4-1.4"/></svg></span><span class="ti-dark"><svg class="i" viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M20.5 14.5A8.5 8.5 0 0 1 9.5 3.5a8.5 8.5 0 1 0 11 11z"/></svg></span><span class="ti-auto"><svg class="i" viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="8.5"/><path d="M12 3.5a8.5 8.5 0 0 1 0 17z" fill="currentColor"/></svg></span></button>
  74. <div class="pop-menu" role="menu"><button type="button" role="menuitemradio" data-theme-set="light" aria-checked="false"><svg class="i" viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="4"/><path d="M12 2.5v2M12 19.5v2M5.3 5.3l1.4 1.4M17.3 17.3l1.4 1.4M2.5 12h2M19.5 12h2M5.3 18.7l1.4-1.4M17.3 6.7l1.4-1.4"/></svg><span>Light</span></button><button type="button" role="menuitemradio" data-theme-set="dark" aria-checked="false"><svg class="i" viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M20.5 14.5A8.5 8.5 0 0 1 9.5 3.5a8.5 8.5 0 1 0 11 11z"/></svg><span>Dark</span></button><button type="button" role="menuitemradio" data-theme-set="auto" aria-checked="false"><svg class="i" viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="8.5"/><path d="M12 3.5a8.5 8.5 0 0 1 0 17z" fill="currentColor"/></svg><span>Auto</span></button></div>
  75. </div>
  76. <a class="btn primary sm nav-dl" href="../download.html">Download</a>
  77. <button type="button" class="icon-btn menu-btn" aria-expanded="false" aria-controls="sheet" aria-label="Menu"><span class="mi-open"><svg class="i" viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M4 9h16M4 15h16"/></svg></span><span class="mi-close"><svg class="i" viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M6 6l12 12M18 6L6 18"/></svg></span></button>
  78. </div>
  79. </div>
  80. <div class="sheet" id="sheet">
  81. <nav class="sheet-links" aria-label="Main">
  82. <a href="../">Overview</a>
  83. <a href="../desktop.html">Desktop</a>
  84. <a href="../media.html">Media</a>
  85. <a href="../office.html">Office</a>
  86. <a href="../ai.html">AI</a>
  87. <a href="../makers.html">Makers</a>
  88. <a href="../storage.html">Storage</a>
  89. <a href="../server.html">Server</a>
  90. <a href="../download.html">Download</a>
  91. </nav>
  92. <div class="sheet-ctl">
  93. <p class="ctl-label">Language</p>
  94. <div class="seg lang-seg" role="menu"><a role="menuitemradio" href="./" hreflang="en" lang="en" data-lang="en" aria-checked="true">English</a><a role="menuitemradio" href="../zh-tw/subservice/" hreflang="zh-Hant" lang="zh-Hant" data-lang="zh-Hant" aria-checked="false">繁體中文</a><a role="menuitemradio" href="../zh-cn/subservice/" hreflang="zh-Hans" lang="zh-Hans" data-lang="zh-Hans" aria-checked="false">简体中文</a><a role="menuitemradio" href="../ja/subservice/" hreflang="ja" lang="ja" data-lang="ja" aria-checked="false">日本語</a></div>
  95. <p class="ctl-label">Appearance</p>
  96. <div class="seg" role="menu"><button type="button" role="menuitemradio" data-theme-set="light" aria-checked="false"><svg class="i" viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="4"/><path d="M12 2.5v2M12 19.5v2M5.3 5.3l1.4 1.4M17.3 17.3l1.4 1.4M2.5 12h2M19.5 12h2M5.3 18.7l1.4-1.4M17.3 6.7l1.4-1.4"/></svg><span>Light</span></button><button type="button" role="menuitemradio" data-theme-set="dark" aria-checked="false"><svg class="i" viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M20.5 14.5A8.5 8.5 0 0 1 9.5 3.5a8.5 8.5 0 1 0 11 11z"/></svg><span>Dark</span></button><button type="button" role="menuitemradio" data-theme-set="auto" aria-checked="false"><svg class="i" viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="8.5"/><path d="M12 3.5a8.5 8.5 0 0 1 0 17z" fill="currentColor"/></svg><span>Auto</span></button></div>
  97. </div>
  98. </div>
  99. </header>
  100. <main id="main">
  101. <section class="hero">
  102. <div class="wrap hero-head">
  103. <p class="eyebrow rv">Developer documentation</p>
  104. <h1 class="hero-title rv" style="--d:1"><span class="grad">Subservices</span></h1>
  105. <p class="hero-sub rv" style="--d:2">Run a binary written in any language. ArozOS starts it, proxies it behind the same login and puts it on the desktop.</p>
  106. </div>
  107. </section>
  108. <section class="notice-sec">
  109. <div class="wrap narrow">
  110. <div class="notice rv" role="note">
  111. <div class="notice-ic"><svg class="i" viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M10.3 4.2L2.8 17.5A2 2 0 0 0 4.5 20.5h15a2 2 0 0 0 1.7-3L13.7 4.2a2 2 0 0 0-3.4 0z"/><path d="M12 9.5v4.2"/><path d="M12 17h.01"/></svg></div>
  112. <div class="notice-body">
  113. <p class="notice-tag">Deprecated</p>
  114. <h2>The subservice infrastructure is no longer maintained</h2>
  115. <p>Subservices still work as described on this page, but they get no new features and no fixes, and they may be removed in a future release. Do not start new projects on them. This page is kept for people who already run one. For new work, use one of these instead:</p>
  116. <ul><li><strong>A WebApp</strong>: HTML and JavaScript in a folder, with server-side AGI scripts for files, databases and the rest of ArozOS.</li><li><strong>A Container App</strong>: publish any web server, in Docker or anywhere else, through the ArozOS port and pin it to the desktop.</li></ul>
  117. <div class="btns"><a class="btn primary" href="../makers.html"><span>WebApps and AGI</span></a><a class="btn secondary" href="../server.html"><span>Container Apps</span></a></div>
  118. </div>
  119. </div>
  120. </div>
  121. </section>
  122. <section class="doc-sec" id="overview">
  123. <div class="wrap narrow">
  124. <div class="doc-head rv">
  125. <p class="eyebrow">Overview</p>
  126. <h2 class="doc-title">A program that ArozOS runs for you</h2>
  127. </div>
  128. <div class="doc-item rv">
  129. <div class="doc-text">A subservice is a separate program, usually a small web server, that ArozOS starts as a child process and reverse-proxies under its own address. It runs outside the core, so it can be written in Go, Rust, Python or anything else that can serve HTTP, and it can use native code that the sandboxed AGI JavaScript runtime cannot.</div>
  130. </div>
  131. <div class="doc-item rv">
  132. <div class="doc-text">Once loaded, it registers as a normal module: it shows up on the desktop and in the start menu, and each user needs permission for it, just like a built-in WebApp.</div>
  133. <p class="note"><strong>Fun fact:</strong> the authenticated reverse proxy that was written for subservices is what <a href="https://zoraxy.aroz.org">Zoraxy</a>, the standalone reverse proxy, grew out of.</p>
  134. </div>
  135. </div>
  136. </section>
  137. <section class="doc-sec" id="layout">
  138. <div class="wrap narrow">
  139. <div class="doc-head rv">
  140. <h2 class="doc-title">Folder layout</h2>
  141. <p class="lead">Every subservice lives in its own folder below <code>subservice/</code>, next to the ArozOS binary. The executable is named after the folder, with the platform added.</p>
  142. </div>
  143. <div class="doc-item rv">
  144. <div class="cmd"><pre><code>subservice/
  145. demo/
  146. demo.exe Windows
  147. demo_linux_amd64 Linux, x86-64
  148. demo_linux_arm64 Linux, ARM64
  149. demo_darwin_amd64 macOS, Intel
  150. moduleInfo.json optional, see &#34;Describing the module&#34;
  151. web/ anything the service serves</code></pre><button type="button" class="copy" data-copy aria-label="Copy" title="Copy"><span class="c-copy"><svg class="i" viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="11" height="11" rx="2.5"/><path d="M5.5 15H5a1.5 1.5 0 0 1-1.5-1.5V5A1.5 1.5 0 0 1 5 3.5h8.5A1.5 1.5 0 0 1 15 5v.5"/></svg></span><span class="c-done"><svg class="i" viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg></span></button></div>
  152. <p class="note">The names are <code>&lt;folder&gt;.exe</code> on Windows and <code>&lt;folder&gt;_&lt;GOOS&gt;_&lt;GOARCH&gt;</code> everywhere else. ArozOS starts the process inside the service folder, so relative paths such as <code>./web</code> work.</p>
  153. </div>
  154. </div>
  155. </section>
  156. <section class="doc-sec" id="startup">
  157. <div class="wrap narrow">
  158. <div class="doc-head rv">
  159. <h2 class="doc-title">What happens at startup</h2>
  160. </div>
  161. <div class="doc-item rv">
  162. <ul class="doc-list"><li>ArozOS looks for the executable of the current platform. A service without one is skipped.</li><li>It reads the module information from <code>moduleInfo.json</code> or, when there is none, runs <code>&lt;binary&gt; -info</code>, which must print the JSON object described below and exit.</li><li>It starts the binary again as a long-running server with the two flags below, and begins proxying to it.</li></ul>
  163. </div>
  164. <div class="doc-item rv">
  165. <div class="doc-text"><code>-port</code> is the next free port counting up from <code>12810</code>. <code>-rpt</code> is the AGI gateway of this ArozOS, the address a subservice calls back (see below).</div>
  166. <div class="cmd"><pre><code>demo_linux_amd64 -port :12810 -rpt http://localhost:8080/api/ajgi/interface</code></pre><button type="button" class="copy" data-copy aria-label="Copy" title="Copy"><span class="c-copy"><svg class="i" viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="11" height="11" rx="2.5"/><path d="M5.5 15H5a1.5 1.5 0 0 1-1.5-1.5V5A1.5 1.5 0 0 1 5 3.5h8.5A1.5 1.5 0 0 1 15 5v.5"/></svg></span><span class="c-done"><svg class="i" viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg></span></button></div>
  167. <p class="note">At boot, a subservice whose module information cannot be read, or that asks for a reserved path, stops ArozOS from starting. When an admin starts a service later, the same problem only shows an error.</p>
  168. </div>
  169. </div>
  170. </section>
  171. <section class="doc-sec" id="module-info">
  172. <div class="wrap narrow">
  173. <div class="doc-head rv">
  174. <h2 class="doc-title">Describing the module</h2>
  175. <p class="lead">The module information is one JSON object. It is the same <code>ModuleInfo</code> that every WebApp registers with, so a subservice appears on the desktop like any other app.</p>
  176. </div>
  177. <div class="doc-item rv">
  178. <div class="cmd"><pre><code>{
  179. &#34;Name&#34;: &#34;Demo Subservice&#34;,
  180. &#34;Desc&#34;: &#34;A simple subservice showing how subservices work in ArozOS&#34;,
  181. &#34;Group&#34;: &#34;Development&#34;,
  182. &#34;IconPath&#34;: &#34;demo/icon.png&#34;,
  183. &#34;Version&#34;: &#34;0.0.1&#34;,
  184. &#34;StartDir&#34;: &#34;demo/home.html&#34;,
  185. &#34;SupportFW&#34;: true,
  186. &#34;LaunchFWDir&#34;: &#34;demo/home.html&#34;,
  187. &#34;SupportEmb&#34;: true,
  188. &#34;LaunchEmb&#34;: &#34;demo/embedded.html&#34;,
  189. &#34;InitFWSize&#34;: [720, 480],
  190. &#34;InitEmbSize&#34;: [720, 480],
  191. &#34;SupportedExt&#34;: [&#34;.txt&#34;, &#34;.md&#34;]
  192. }</code></pre><button type="button" class="copy" data-copy aria-label="Copy" title="Copy"><span class="c-copy"><svg class="i" viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="11" height="11" rx="2.5"/><path d="M5.5 15H5a1.5 1.5 0 0 1-1.5-1.5V5A1.5 1.5 0 0 1 5 3.5h8.5A1.5 1.5 0 0 1 15 5v.5"/></svg></span><span class="c-done"><svg class="i" viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg></span></button></div>
  193. <p class="note">The folder part of <code>StartDir</code> (here <code>demo</code>) becomes the proxy endpoint. It must not be empty or one of the reserved paths <code>web</code>, <code>system</code>, <code>SystemAO</code>, <code>img</code>, <code>STDIN</code>, <code>STDOUT</code>, <code>STDERR</code>, <code>COM</code>, <code>ws</code>, <code>cluster</code> and <code>app</code>.</p>
  194. </div>
  195. </div>
  196. </section>
  197. <section class="specs-sec tone-alt">
  198. <div class="wrap narrow">
  199. <div class="sec-head rv">
  200. <h2 class="title">Module fields</h2>
  201. </div>
  202. <dl class="specs"><div class="spec rv">
  203. <dt>Name</dt>
  204. <dd><p>Shown on the desktop. Access is granted by this name, so keep it unique.</p></dd>
  205. </div><div class="spec rv">
  206. <dt>Desc</dt>
  207. <dd><p>A short description.</p></dd>
  208. </div><div class="spec rv">
  209. <dt>Group</dt>
  210. <dd><p>Start menu category: <code>Media</code>, <code>Office</code>, <code>Internet</code>, <code>Engineering</code>, <code>Development</code>, <code>System Tools</code> or <code>Utilities</code>; anything else is listed under Other. <code>Utilities</code> and <code>System Tools</code> are open to every user, every other group needs a permission group grant.</p></dd>
  211. </div><div class="spec rv">
  212. <dt>IconPath</dt>
  213. <dd><p>The icon, as a path the service serves, such as <code>demo/icon.png</code>.</p></dd>
  214. </div><div class="spec rv">
  215. <dt>Version</dt>
  216. <dd><p>A version string such as <code>0.0.1</code>.</p></dd>
  217. </div><div class="spec rv">
  218. <dt>StartDir</dt>
  219. <dd><p>The page that opens in a full page window. Its folder is the proxy endpoint.</p></dd>
  220. </div><div class="spec rv">
  221. <dt>SupportFW, LaunchFWDir, InitFWSize</dt>
  222. <dd><p>Open in a floating window: whether it is supported, the page to load and the starting size as <code>[width, height]</code>.</p></dd>
  223. </div><div class="spec rv">
  224. <dt>SupportEmb, LaunchEmb, InitEmbSize</dt>
  225. <dd><p>Embedded mode, which is what loads when a file is opened with the module. Same three settings.</p></dd>
  226. </div><div class="spec rv">
  227. <dt>SupportedExt</dt>
  228. <dd><p>File extensions the module can open, such as <code>[".txt", ".md"]</code>. They let it become a default opener.</p></dd>
  229. </div></dl>
  230. </div>
  231. </section>
  232. <section class="doc-sec" id="proxy">
  233. <div class="wrap narrow">
  234. <div class="doc-head rv">
  235. <h2 class="doc-title">How requests reach the service</h2>
  236. </div>
  237. <div class="doc-item rv">
  238. <ul class="doc-list"><li>Only signed in users who have permission for the module get through. Everyone else receives a 404.</li><li>The endpoint folder is removed from the path: <code>/demo/api/list?a=1</code> reaches the service as <code>/api/list?a=1</code> and <code>/demo/</code> as <code>/</code>. Pages should therefore use relative links, or links that begin with the endpoint folder: a link to <code>/api/list</code> would hit ArozOS itself.</li><li>ArozOS adds three request headers: <code>aouser</code> (the user name), <code>aotoken</code> (a token for that user) and <code>X-Forwarded-Host</code> (the host the browser used).</li><li>WebSocket connections are proxied as well. Those requests also carry <code>A-Upgrade: websocket</code>.</li><li>If the service stops answering, ArozOS logs it, kills the process and starts it again after 10 seconds.</li></ul>
  239. <p class="note">The headers are only as trustworthy as the port. A service that listens on all interfaces lets anyone who can reach the port send <code>aouser</code> themselves, so bind to <code>127.0.0.1</code> or block the ports from <code>12810</code> upward from outside.</p>
  240. </div>
  241. </div>
  242. </section>
  243. <section class="doc-sec" id="agi">
  244. <div class="wrap narrow">
  245. <div class="doc-head rv">
  246. <h2 class="doc-title">Calling back into ArozOS</h2>
  247. <p class="lead">A subservice reaches ArozOS functions through the AGI gateway, the address it received in <code>-rpt</code>. POST the user's token and a script. The script runs in the AGI runtime with that user's permissions, and whatever it sends with <code>sendJSONResp</code> is the response body.</p>
  248. </div>
  249. <div class="doc-item rv">
  250. <div class="cmd"><pre><code>func listDesktop(w http.ResponseWriter, r *http.Request) {
  251. token := r.Header.Get(&#34;aotoken&#34;)
  252. script := `
  253. requirelib(&#34;filelib&#34;);
  254. var list = filelib.glob(&#34;user:/Desktop/*&#34;);
  255. sendJSONResp(JSON.stringify(list));
  256. `
  257. // rpt is the value of the -rpt flag
  258. resp, err := http.PostForm(rpt, url.Values{
  259. &#34;token&#34;: {token},
  260. &#34;script&#34;: {script},
  261. })
  262. if err != nil {
  263. http.Error(w, err.Error(), http.StatusBadGateway)
  264. return
  265. }
  266. defer resp.Body.Close()
  267. w.Header().Set(&#34;Content-Type&#34;, &#34;application/json&#34;)
  268. io.Copy(w, resp.Body)
  269. }</code></pre><button type="button" class="copy" data-copy aria-label="Copy" title="Copy"><span class="c-copy"><svg class="i" viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="11" height="11" rx="2.5"/><path d="M5.5 15H5a1.5 1.5 0 0 1-1.5-1.5V5A1.5 1.5 0 0 1 5 3.5h8.5A1.5 1.5 0 0 1 15 5v.5"/></svg></span><span class="c-done"><svg class="i" viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg></span></button></div>
  270. <p class="note">The form fields are <code>token</code> (the <code>aotoken</code> header of the request) and <code>script</code>. The status code of the reply is not enough to know the script worked, so check what it returned.</p>
  271. </div>
  272. </div>
  273. </section>
  274. <section class="doc-sec" id="example">
  275. <div class="wrap narrow">
  276. <div class="doc-head rv">
  277. <h2 class="doc-title">A minimal service</h2>
  278. <p class="lead">This Go program answers <code>-info</code>, serves a <code>web/</code> folder and has one API that greets the signed in user.</p>
  279. </div>
  280. <div class="doc-item rv">
  281. <div class="doc-text">The complete example, with a web page, an AGI call, an icon and build scripts for every platform, is in the example repository.</div>
  282. <div class="cmd"><pre><code>package main
  283. import (
  284. &#34;encoding/json&#34;
  285. &#34;flag&#34;
  286. &#34;fmt&#34;
  287. &#34;log&#34;
  288. &#34;net/http&#34;
  289. )
  290. func main() {
  291. info := flag.Bool(&#34;info&#34;, false, &#34;print the module information and exit&#34;)
  292. port := flag.String(&#34;port&#34;, &#34;:8000&#34;, &#34;listen address chosen by ArozOS&#34;)
  293. flag.String(&#34;rpt&#34;, &#34;&#34;, &#34;AGI gateway of ArozOS&#34;)
  294. flag.Parse()
  295. if *info {
  296. b, _ := json.Marshal(map[string]any{
  297. &#34;Name&#34;: &#34;Demo Subservice&#34;,
  298. &#34;Desc&#34;: &#34;A simple subservice&#34;,
  299. &#34;Group&#34;: &#34;Development&#34;,
  300. &#34;IconPath&#34;: &#34;demo/icon.png&#34;,
  301. &#34;Version&#34;: &#34;0.0.1&#34;,
  302. &#34;StartDir&#34;: &#34;demo/home.html&#34;,
  303. &#34;SupportFW&#34;: true,
  304. &#34;LaunchFWDir&#34;: &#34;demo/home.html&#34;,
  305. &#34;InitFWSize&#34;: []int{720, 480},
  306. })
  307. fmt.Println(string(b))
  308. return
  309. }
  310. http.HandleFunc(&#34;/whoami&#34;, func(w http.ResponseWriter, r *http.Request) {
  311. fmt.Fprintln(w, &#34;Hello&#34;, r.Header.Get(&#34;aouser&#34;))
  312. })
  313. http.Handle(&#34;/&#34;, http.FileServer(http.Dir(&#34;./web&#34;)))
  314. log.Println(&#34;demo listening on&#34;, *port)
  315. log.Fatal(http.ListenAndServe(*port, nil))
  316. }</code></pre><button type="button" class="copy" data-copy aria-label="Copy" title="Copy"><span class="c-copy"><svg class="i" viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="11" height="11" rx="2.5"/><path d="M5.5 15H5a1.5 1.5 0 0 1-1.5-1.5V5A1.5 1.5 0 0 1 5 3.5h8.5A1.5 1.5 0 0 1 15 5v.5"/></svg></span><span class="c-done"><svg class="i" viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg></span></button></div>
  317. <div class="btns"><a class="btn secondary" href="https://github.com/aroz-online/ArozOS-Subservice-Example" target="_blank" rel="noopener"><svg class="i" viewBox="0 0 16 16" aria-hidden="true" fill="currentColor"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"/></svg><span>Subservice example</span></a></div>
  318. </div>
  319. </div>
  320. </section>
  321. <section class="specs-sec tone-alt" id="marker-files">
  322. <div class="wrap narrow">
  323. <div class="sec-head rv">
  324. <h2 class="title">Marker files</h2>
  325. <p class="lead">Empty files placed in the service folder change how it is started. They are read each time the service starts.</p>
  326. </div>
  327. <dl class="specs"><div class="spec rv">
  328. <dt>.disabled</dt>
  329. <dd><p>Skip this service at boot. ArozOS writes it itself when an admin stops the service, and removes it when the service is started again.</p></dd>
  330. </div><div class="spec rv">
  331. <dt>.noproxy</dt>
  332. <dd><p>Compatibility mode. The program is started without arguments and no proxy is set up, for software that was not written for ArozOS.</p></dd>
  333. </div><div class="spec rv">
  334. <dt>.startscript</dt>
  335. <dd><p>Start <code>start.sh</code> (<code>start.bat</code> on Windows) from the service folder instead of the binary, for example to wrap a program that needs more arguments. The script receives <code>-port</code> and <code>-rpt</code> like a binary would.</p></dd>
  336. </div><div class="spec rv">
  337. <dt>.intport</dt>
  338. <dd><p>Pass the port as <code>12810</code> instead of <code>:12810</code>, for programs that do not accept a leading colon.</p></dd>
  339. </div><div class="spec rv">
  340. <dt>moduleInfo.json</dt>
  341. <dd><p>The module information as a file. When it exists, ArozOS does not run the binary with <code>-info</code>.</p></dd>
  342. </div></dl>
  343. </div>
  344. </section>
  345. <section class="doc-sec" id="runtime">
  346. <div class="wrap narrow">
  347. <div class="doc-head rv">
  348. <h2 class="doc-title">Managing services</h2>
  349. <p class="lead">Admins start and stop services from System Settings, which uses these endpoints:</p>
  350. </div>
  351. <div class="doc-item rv">
  352. <ul class="doc-list"><li><code>/system/subservice/list</code> lists the running and the disabled services.</li><li><code>/system/subservice/kill</code> stops a service. Admin only, with the form field <code>serviceDir</code> set to its folder name.</li><li><code>/system/subservice/start</code> starts one. Admin only, same field.</li></ul>
  353. <p class="note">Start ArozOS with <code>-disable_subservice</code> to turn the whole feature off.</p>
  354. </div>
  355. </div>
  356. </section>
  357. <section class="cta">
  358. <div class="wrap narrow rv">
  359. <div class="cta-logo"><svg class="logo" viewBox="0 0 256 256" aria-hidden="true"><rect class="logo-bg" width="256" height="256" rx="58"/><path class="logo-fg" d="M70 58h116l-58 70zM128 128l58 70H70z"/></svg></div>
  360. <h2 class="title">Already running a subservice?</h2>
  361. <p class="lead">The example repository is the best reference for how one is built. Keep in mind that the infrastructure is no longer maintained.</p>
  362. <div class="btns center"><a class="btn primary" href="https://github.com/aroz-online/ArozOS-Subservice-Example" target="_blank" rel="noopener"><svg class="i" viewBox="0 0 16 16" aria-hidden="true" fill="currentColor"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"/></svg><span>Subservice example</span></a><a class="btn secondary" href="../makers.html"><span>Build a WebApp instead</span></a></div>
  363. </div>
  364. </section>
  365. </main>
  366. <footer class="foot">
  367. <div class="wrap">
  368. <div class="foot-top">
  369. <div class="foot-brand">
  370. <a class="brand" href="../" aria-label="ArozOS"><svg class="logo" viewBox="0 0 256 256" aria-hidden="true"><rect class="logo-bg" width="256" height="256" rx="58"/><path class="logo-fg" d="M70 58h116l-58 70zM128 128l58 70H70z"/></svg><span>ArozOS</span></a>
  371. <p>The web desktop for the server you own.</p>
  372. </div>
  373. <div class="foot-col">
  374. <h2>Explore</h2>
  375. <ul><li><a href="../desktop.html">Desktop</a></li><li><a href="../media.html">Media</a></li><li><a href="../office.html">Office</a></li><li><a href="../ai.html">AI</a></li><li><a href="../makers.html">Makers</a></li><li><a href="../storage.html">Storage</a></li><li><a href="../server.html">Server</a></li><li><a href="../download.html">Download</a></li></ul>
  376. </div>
  377. <div class="foot-col">
  378. <h2>Developers</h2>
  379. <ul><li><a href="https://aroz-online.github.io/ArozOS-Developers/" target="_blank" rel="noopener">AGI documentation</a></li><li><a href="https://github.com/aroz-online/WebApp-and-Subservice-Index" target="_blank" rel="noopener">WebApps and subservices</a></li><li><a href="./">Subservices (deprecated)</a></li><li><a href="https://github.com/aroz-online/ArozOS-Subservice-Example" target="_blank" rel="noopener">Subservice example</a></li><li><a href="../ArozOS-Cluster-Whitepaper.pdf">Cluster whitepaper</a></li><li><a href="https://github.com/aroz-online/launcher" target="_blank" rel="noopener">ArozOS Launcher</a></li></ul>
  380. </div>
  381. <div class="foot-col">
  382. <h2>Community</h2>
  383. <ul><li><a href="https://github.com/tobychui/arozos" target="_blank" rel="noopener">Source code</a></li><li><a href="https://github.com/tobychui/arozos/releases" target="_blank" rel="noopener">Releases</a></li><li><a href="https://github.com/tobychui/arozos/issues" target="_blank" rel="noopener">Report an issue</a></li><li><a href="https://t.me/ArOZBeta" target="_blank" rel="noopener">Telegram</a></li><li><a href="mailto:toby@imuslab.com">Email</a></li></ul>
  384. </div>
  385. <div class="foot-col">
  386. <h2>Projects</h2>
  387. <ul><li><a href="https://zoraxy.aroz.org" target="_blank" rel="noopener">Zoraxy</a></li><li><a href="https://github.com/tobychui/imusutm" target="_blank" rel="noopener">imusutm</a></li><li><a href="https://github.com/tobychui/SlicerA" target="_blank" rel="noopener">Slicer A</a></li><li><a href="https://github.com/SysAdmin74/ArozOS-Docker" target="_blank" rel="noopener">ArozOS Docker (community)</a></li><li><a href="https://imuslab.com" target="_blank" rel="noopener">imuslab</a></li></ul>
  388. </div>
  389. </div>
  390. <div class="foot-bottom">
  391. <p>Copyright © 2016–<span data-year>2026</span> Toby Chui feat. imuslab. Made in Hong Kong. Open source under <a href="https://github.com/tobychui/arozos/blob/master/LICENSE">GPLv3</a>.</p>
  392. <div class="foot-ctl">
  393. <div class="seg sm" role="menu" aria-label="Appearance"><button type="button" role="menuitemradio" data-theme-set="light" aria-checked="false"><svg class="i" viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="4"/><path d="M12 2.5v2M12 19.5v2M5.3 5.3l1.4 1.4M17.3 17.3l1.4 1.4M2.5 12h2M19.5 12h2M5.3 18.7l1.4-1.4M17.3 6.7l1.4-1.4"/></svg><span>Light</span></button><button type="button" role="menuitemradio" data-theme-set="dark" aria-checked="false"><svg class="i" viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M20.5 14.5A8.5 8.5 0 0 1 9.5 3.5a8.5 8.5 0 1 0 11 11z"/></svg><span>Dark</span></button><button type="button" role="menuitemradio" data-theme-set="auto" aria-checked="false"><svg class="i" viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="8.5"/><path d="M12 3.5a8.5 8.5 0 0 1 0 17z" fill="currentColor"/></svg><span>Auto</span></button></div>
  394. <div class="foot-langs" role="menu" aria-label="Language"><a role="menuitemradio" href="./" hreflang="en" lang="en" data-lang="en" aria-checked="true">English</a><a role="menuitemradio" href="../zh-tw/subservice/" hreflang="zh-Hant" lang="zh-Hant" data-lang="zh-Hant" aria-checked="false">繁體中文</a><a role="menuitemradio" href="../zh-cn/subservice/" hreflang="zh-Hans" lang="zh-Hans" data-lang="zh-Hans" aria-checked="false">简体中文</a><a role="menuitemradio" href="../ja/subservice/" hreflang="ja" lang="ja" data-lang="ja" aria-checked="false">日本語</a></div>
  395. </div>
  396. </div>
  397. </div>
  398. </footer>
  399. </body>
  400. </html>