markdown to html

This commit is contained in:
Denis Zheleztsov 2017-01-12 13:11:01 +03:00
parent d74c36eed1
commit b7291450e1
11 changed files with 417 additions and 22 deletions

46
docs/App-config-file.html Normal file
View File

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>App-config-file.html</title>
</head>
<body>
<h1>Surok app config file</h1>
<p>conf.d/myapp.json
<code>
{
"services": [
{
"name": "myapp",
"group": "backend.production",
"ports": ["proxy", "api"]
},
{
"name": "nginx",
"group": "frontend.production"
}
],
"conf_name": "myapp_backend_production",
"template": "/etc/surok/templates/myapp.jj2",
"dest": "/etc/myapp/myapp.cfg",
"reload_cmd": "killall -9 myapp; /usr/local/bin/myapp -config /etc/myapp/myapp.cfg"
}
</code>
* <strong>services</strong>. List of hashes with required services for app.
1. <em>name</em> - string. App name in Marathon.
2. <em>group</em> - string. App group in Marathon. Optional. Discovery policy: 1) config 2) SUROK<em>DISCOVERY</em>GROUP environment variable 3) Marathon API
3. <em>ports</em> - list. Name of opened port. In marathon of course. Optional.
* <strong>conf<em>name</strong>. Unique app config name.
* <strong>template</strong>. Jinja2 template location.
* <strong>dest</strong>. Destination config path.
* <strong>reload</em>cmd</strong>. Command to execute if generated config is changed.</p>
</body>
</html>

View File

@ -1,3 +1,5 @@
# Surok app config file
conf.d/myapp.json
```
{
@ -25,4 +27,4 @@ conf.d/myapp.json
* **conf_name**. Unique app config name.
* **template**. Jinja2 template location.
* **dest**. Destination config path.
* **reload_cmd**. Command to execute if generated config is changed.
* **reload_cmd**. Command to execute if generated config is changed.

44
docs/Build.html Normal file
View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Build.html</title>
</head>
<body>
<h1>Build packages and images</h1>
<p>build debian package
<code>
cd build
./build.sh build_package
</code>
A deb-package will be placed in build/out</p>
<p>build surok base docker image(based on Ubuntu Xenial)
<code>
cd build
./build.sh surok_image
</code></p>
<p>build surok base Alpine image
<code>
cd build
./build.sh alpine
</code></p>
<p>build surok base CentOS image
<code>
cd build
./build.sh centos
</code></p>
<p>ENTRYPOINT is: <code>cd /opt/surok &amp;&amp; pytho3 surok.py -c /etc/surok/conf/surok.json</code></p>
</body>
</html>

View File

@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Main-config-file.html</title>
</head>
<body>
<h1>Surok main config file</h1>
<p>Default location is /etc/surok/conf/surok.json</p>
<p>conf/surok.json
<code>
{
"marathon": {
"force": true,
"host": "http://marathon.mesos:8080",
"enabled": false
},
"confd": "/etc/surok/conf.d",
"domain": "marathon.mesos",
"wait_time": 20,
"lock_dir": "/var/tmp",
"loglevel": "info",
"container": false,
"memcached": {
"enabled": false,
"discovery": {
"enabled": false,
"service": "memcached",
"group": "system"
},
"hosts": ["localhost:11211"]
}
}
</code>
* <strong>marathon section</strong>. Restarting app over marathon api if config changed. Disabled by default.
* <strong>confd</strong>. Directory where located configs apps.
* <strong>domain</strong>. Domain served by mesos-dns.
* <strong>lock<em>dir</strong>. Directory where surok writes temporary configs after resolving.
* <strong>wait</em>time</strong>. Sleep time in main loop.
* <strong>container</strong>. Not implemented.
* <strong>memcached section</strong>. Memcached support. Disabled by default.</p>
</body>
</html>

View File

@ -1,3 +1,7 @@
# Surok main config file
Default location is /etc/surok/conf/surok.json
conf/surok.json
```
{
@ -5,7 +9,7 @@ conf/surok.json
"force": true,
"host": "http://marathon.mesos:8080",
"enabled": false
},
},
"confd": "/etc/surok/conf.d",
"domain": "marathon.mesos",
"wait_time": 20,
@ -13,13 +17,13 @@ conf/surok.json
"loglevel": "info",
"container": false,
"memcached": {
"enabled": false,
"discovery": {
"enabled": false,
"discovery": {
"enabled": false,
"service": "memcached",
"group": "system"
},
"hosts": ["localhost:11211"]
"service": "memcached",
"group": "system"
},
"hosts": ["localhost:11211"]
}
}
```
@ -29,4 +33,4 @@ conf/surok.json
* **lock_dir**. Directory where surok writes temporary configs after resolving.
* **wait_time**. Sleep time in main loop.
* **container**. Not implemented.
* **memcached section**. Memcached support. Disabled by default.
* **memcached section**. Memcached support. Disabled by default.

View File

@ -11,14 +11,14 @@ Service discovery for Apache Mesos.
**Table of Contents**
- [Surok](https://difrex.github.io/surok/)
- [Build](https://difrex.github.io/surok/Build.md)
- [Build](https://difrex.github.io/surok/Build.html)
- [Wiki](https://github.com/Difrex/surok/wiki)
- **Configuration**
- [Main config file](https://difrex.github.io/surok/Main-config-file.md)
- [App config file](https://difrex.github.io/surok/App-config-file.md)
- [Templates](https://difrex.github.io/surok/Templates.md)
- [Main config file](https://difrex.github.io/surok/Main-config-file.html)
- [App config file](https://difrex.github.io/surok/App-config-file.html)
- [Templates](https://difrex.github.io/surok/Templates.html)
- **Usage**
- [Use Surok with Supervisord](https://difrex.github.io/surok/Use-Surok-with-supervisord.md)
- [Use Surok with Supervisord](https://difrex.github.io/surok/Use-Surok-with-supervisord.html)
- [Known issues](#known-issues)
- [Athors](#authors)
- [LICENSE](#license)

132
docs/Templates.html Normal file
View File

@ -0,0 +1,132 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Templates.html</title>
</head>
<body>
<h1>Templates</h1>
<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-generate-toc again -->
**Table of Contents**
- [Templates](#templates)
- [my dictionary in templates](#my-dictionary-in-templates)
- [Real template example](#real-template-example)
- [Checks in template](#checks-in-template)
<!-- markdown-toc end -->
<p>Surok using Jinja2 for templates. <a href="http://jinja.pocoo.org/docs/dev/">Jinja2 documentation</a></p>
<h2>my dictionary in templates</h2>
<p><code>
{
"services": {
"nginx": [
{
"name": "nginx.testing-kl92-s0.marathon.mesos.",
"port": "31200",
"ip": ["10.10.10.1"]
},
{
"name": "nginx.testing-kl123-s1.marathon.mesos.",
"port": "32230",
"ip": ["10.10.10.2"]
}
],
"emailsender": [
{
"name": "emailsender.testing-kl92-s0.marathon.mesos.",
"port": "31201",
"ip": ["10.10.10.1"]
},
{
"name": "emailsender.testing-kl123-s1.marathon.mesos.",
"port": "32232",
"ip": ["10.10.10.1"]
}
],
"service-with-defined-ports": {
"web": [
{
"name": "f.q.d.n",
"port": 12341
}
],
"rpc": [
{
"name": "f.q.d.n",
"port": 12342
}
]
}
},
"env": {
"HOME": "/var/lib/nginx"
}
}
</code></p>
<h2>Real template example</h2>
<p>nginx config
```
upstream matrix-http {
hash $remote<em>addr;
{% for server in my['services']['matrix']['http'] %}
server {{server['name']}}:{{server['port']}} max</em>fails=3;
{% endfor %}
}</p>
<p>upstream riot-http {
hash $remote<em>addr;
{% for server in my['services']['riot'] %}
server {{server['name']}}:{{server['port']}} max</em>fails=3;
{% endfor %}
}</p>
<p>server {
listen 10.15.56.157:80;
server_name matrix.example.com;</p>
<pre><code>client_max_body_size 10m;
location / {
proxy_pass http://riot-http;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /_matrix/ {
proxy_pass http://matrix-http;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
</code></pre>
<p>}
```</p>
<h2>Checks in template</h2>
<p><em>my['env']</em> is a python os.environ class. Look bellow:
<code>
{% if my['env'].get('DB_HOST') %}
host = '{{my['env']['DB_HOST']}}'
{% else %}
host = 'localhost'
{% endif %}
</code></p>
</body>
</html>

View File

@ -1,5 +1,16 @@
# Templates
<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-generate-toc again -->
**Table of Contents**
- [Templates](#templates)
- [my dictionary in templates](#my-dictionary-in-templates)
- [Real template example](#real-template-example)
- [Checks in template](#checks-in-template)
<!-- markdown-toc end -->
Surok using Jinja2 for templates. [Jinja2 documentation](http://jinja.pocoo.org/docs/dev/)
## my dictionary in templates

View File

@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Use-Surok-with-supervisord.html</title>
</head>
<body>
<h1>Use Surok with supervisord</h1>
<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-generate-toc again -->
**Table of Contents**
- [Use Surok with supervisord](#use-surok-with-supervisord)
- [supervisord.conf](#supervisordconf)
- [surok service conf](#surok-service-conf)
- [install supervisord in you container and set it as entrypoint](#install-supervisord-in-you-container-and-set-it-as-entrypoint)
<!-- markdown-toc end -->
<h2>supervisord.conf</h2>
<p>Write supervisord.conf. Example:
```ini
[unix<em>http</em>server]
file=/tmp/supervisor.sock</p>
<p>[supervisord]
logfile=/tmp/supervisord.log ; (main log file;default $CWD/supervisord.log)
logfile<em>maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
logfile</em>backups=10 ; (num of main logfile rotation backups;default 10)
loglevel=info ; (log level;default info; others: debug,warn,trace)
pidfile=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=true ; (start in foreground if true;default false)
minfds=1024 ; (min. avail startup file descriptors;default 1024)
minprocs=200</p>
<p>[supervisorctl]
serverurl=unix:///tmp/supervisor.sock</p>
<p>[rpcinterface:supervisor]
supervisor.rpcinterface<em>factory = supervisor.rpcinterface:make</em>main_rpcinterface</p>
<p>[program:surok]
command=/usr/bin/python3 /opt/surok/surok.py -c /etc/surok/conf/surok.json</p>
<p>[program:my<em>service]
command=/app/my</em>service -conf /app/conf/my_service.conf
user=www-data
startsecs=2
```</p>
<h2>surok service conf</h2>
<p>Write /etc/surok/conf.d/my_service.json config like that
```json
{
"services": [
{
"name": "my-service",
"group": "production.web"
}</p>
<pre><code>],
"conf_name": "my_service",
"template": "/etc/surok/templates/my-service.jj2",
"dest": "/app/conf/my_service.conf",
"reload_cmd": "/usr/bin/supervisorctl restart my_service"
</code></pre>
<p>}
```</p>
<h2>install supervisord in you container and set it as entrypoint</h2>
<p>```dockerfile
...</p>
<h1>Install supervisord and provide config</h1>
<p>RUN easy_install supervisor
ADD supervisord.conf /etc</p>
<p>ENTRYPOINT /usr/bin/supervisord -c /etc/supervisord.conf
```</p>
</body>
</html>

View File

@ -1,5 +1,16 @@
# Use Surok with supervisord
<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-generate-toc again -->
**Table of Contents**
- [Use Surok with supervisord](#use-surok-with-supervisord)
- [supervisord.conf](#supervisordconf)
- [surok service conf](#surok-service-conf)
- [install supervisord in you container and set it as entrypoint](#install-supervisord-in-you-container-and-set-it-as-entrypoint)
<!-- markdown-toc end -->
## supervisord.conf
Write supervisord.conf. Example:
```ini
@ -57,4 +68,4 @@ RUN easy_install supervisor
ADD supervisord.conf /etc
ENTRYPOINT /usr/bin/supervisord -c /etc/supervisord.conf
```
```

View File

@ -28,17 +28,17 @@
<ul>
<li><a href="https://difrex.github.io/surok/">Surok</a>
<ul>
<li><a href="https://difrex.github.io/surok/Build.md">Build</a></li>
<li><a href="https://difrex.github.io/surok/Build.html">Build</a></li>
<li><a href="https://github.com/Difrex/surok/wiki">Wiki</a></li>
<li><strong>Configuration</strong>
<ul>
<li><a href="https://difrex.github.io/surok/Main-config-file.md">Main config file</a></li>
<li><a href="https://difrex.github.io/surok/App-config-file.md">App config file</a></li>
<li><a href="https://difrex.github.io/surok/Templates.md">Templates</a></li>
<li><a href="https://difrex.github.io/surok/Main-config-file.html">Main config file</a></li>
<li><a href="https://difrex.github.io/surok/App-config-file.html">App config file</a></li>
<li><a href="https://difrex.github.io/surok/Templates.html">Templates</a></li>
</ul></li>
<li><strong>Usage</strong>
<ul>
<li><a href="https://difrex.github.io/surok/Use-Surok-with-supervisord.md">Use Surok with Supervisord</a></li>
<li><a href="https://difrex.github.io/surok/Use-Surok-with-supervisord.html">Use Surok with Supervisord</a></li>
</ul></li>
</ul></li>
<li><a href="#known-issues">Known issues</a></li>
@ -55,8 +55,8 @@
<h2>Authors</h2>
<ul>
<li>Denis Zheleztsov <a href="&#x6D;&#97;&#x69;&#x6C;&#x74;&#x6F;:&#x64;&#105;&#102;&#114;&#x65;&#120;&#46;p&#117;&#110;&#x6B;&#64;&#103;&#x6D;&#97;&#105;&#x6C;&#x2E;&#x63;&#x6F;&#x6D;">&#x64;&#105;&#102;&#114;&#x65;&#120;&#46;p&#117;&#110;&#x6B;&#64;&#103;&#x6D;&#97;&#105;&#x6C;&#x2E;&#x63;&#x6F;&#x6D;</a></li>
<li>Denis Ryabyy <a href="&#109;&#97;&#105;&#108;&#116;&#111;:&#118;v&#49;r0&#120;&#64;&#103;&#109;&#x61;&#105;&#x6C;&#x2E;&#x63;&#x6F;&#x6D;">&#118;v&#49;r0&#120;&#64;&#103;&#109;&#x61;&#105;&#x6C;&#x2E;&#x63;&#x6F;&#x6D;</a></li>
<li>Denis Zheleztsov <a href="&#109;&#97;&#105;&#x6C;t&#x6F;:&#x64;&#x69;&#102;&#114;&#101;x&#46;&#112;&#117;&#x6E;&#107;&#64;&#103;&#109;&#97;&#x69;l&#46;&#x63;&#111;&#109;">&#x64;&#x69;&#102;&#114;&#101;x&#46;&#112;&#117;&#x6E;&#107;&#64;&#103;&#109;&#97;&#x69;l&#46;&#x63;&#111;&#109;</a></li>
<li>Denis Ryabyy <a href="&#109;&#97;&#x69;&#x6C;&#116;&#111;:&#118;&#x76;&#49;&#x72;&#x30;&#x78;&#64;&#x67;&#109;&#97;&#x69;&#x6C;&#x2E;&#99;&#111;&#109;">&#118;&#x76;&#49;&#x72;&#x30;&#x78;&#64;&#x67;&#109;&#97;&#x69;&#x6C;&#x2E;&#99;&#111;&#109;</a></li>
</ul>
<h2>LICENSE</h2>