Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Xavier Thompson
slapos
Commits
2c343a23
Commit
2c343a23
authored
Sep 27, 2021
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
html5as: Add demo for local promise egg
parent
acc99f4c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
146 additions
and
1 deletion
+146
-1
software/html5as/buildout.hash.cfg
software/html5as/buildout.hash.cfg
+1
-1
software/html5as/instance_html5as.cfg.in
software/html5as/instance_html5as.cfg.in
+13
-0
software/html5as/mypromise/promise.py
software/html5as/mypromise/promise.py
+57
-0
software/html5as/mypromise/setup.py
software/html5as/mypromise/setup.py
+49
-0
software/html5as/software.cfg
software/html5as/software.cfg
+26
-0
No files found.
software/html5as/buildout.hash.cfg
View file @
2c343a23
...
...
@@ -21,7 +21,7 @@ md5sum = 9e486efe4ab1aba8cb72b04f6c6da8ad
[instance_html5as]
_update_hash_filename_ = instance_html5as.cfg.in
md5sum = 2
83440057c659bde2ae7fcc2c4c5b781
md5sum = 2
153820e7dac9fc9f7369304f0cec95f
[template_nginx_conf]
_update_hash_filename_ = templates/nginx_conf.in
...
...
software/html5as/instance_html5as.cfg.in
View file @
2c343a23
...
...
@@ -14,6 +14,7 @@ parts =
launcher
nginx-graceful
port-listening-promise
port-listening-mypromise
logrotate-entry-nginx
publish-connection-information
...
...
@@ -190,6 +191,18 @@ name = nginx-port-listening.py
config-host = ${html5as:ip}
config-port = ${html5as:port}
# Port Listening checking promise using mypromise egg
[port-listening-mypromise]
recipe = slapos.cookbook:promise.plugin
eggs = slapos.mypromise.html5as
mode = 600
content = from promise import RunPromise
output = ${directory:plugins}/nginx-port-listening-mypromise.py
config-host = ${html5as:ip}
config-port = ${html5as:port}
# Use a port different from the default one in order to be able to
# use it in a SlapOS webrunner or a Theia SlapOS Runner
[monitor-instance-parameter]
...
...
software/html5as/mypromise/promise.py
0 → 100644
View file @
2c343a23
from
zope.interface
import
implementer
from
slapos.grid.promise
import
interface
from
slapos.grid.promise.generic
import
GenericPromise
import
socket
ADDRESS_USAGE
=
(
"Address must be specified in 1 of the following 3 forms:"
" (host, port), path or abstract"
)
@
implementer
(
interface
.
IPromise
)
class
RunPromise
(
GenericPromise
):
def
__init__
(
self
,
config
):
super
(
RunPromise
,
self
).
__init__
(
config
)
self
.
setPeriodicity
(
minute
=
2
)
self
.
result_count
=
int
(
self
.
getConfig
(
'result-count'
,
3
))
self
.
failure_amount
=
int
(
self
.
getConfig
(
'failure-amount'
,
3
))
def
sense
(
self
):
"""
Check the state of a socket.
"""
host
=
self
.
getConfig
(
'host'
)
port
=
self
.
getConfig
(
'port'
)
path
=
self
.
getConfig
(
'pathname'
)
abstract
=
self
.
getConfig
(
'abstract'
)
if
host
:
if
path
or
abstract
or
not
port
:
self
.
logger
.
error
(
ADDRESS_USAGE
)
return
# type of port must be int or str, unicode is not accepted.
family
,
_
,
_
,
_
,
addr
=
socket
.
getaddrinfo
(
host
,
int
(
port
))[
0
]
else
:
if
bool
(
path
)
==
bool
(
abstract
):
self
.
logger
.
error
(
ADDRESS_USAGE
)
return
family
=
socket
.
AF_UNIX
addr
=
path
or
'
\
0
'
+
abstract
s
=
socket
.
socket
(
family
,
socket
.
SOCK_STREAM
)
try
:
s
.
connect
(
addr
)
except
socket
.
error
as
e
:
self
.
logger
.
error
(
'%s: %s'
,
type
(
e
).
__name__
,
e
)
else
:
self
.
logger
.
info
(
"socket connection OK %r"
,
addr
)
finally
:
s
.
close
()
def
anomaly
(
self
):
"""
By default, there is an anomaly if last 3 senses were bad.
"""
return
self
.
_anomaly
(
result_count
=
self
.
result_count
,
failure_amount
=
self
.
failure_amount
)
software/html5as/mypromise/setup.py
0 → 100644
View file @
2c343a23
##############################################################################
#
# Copyright (c) 2019 Nexedi SA and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from
setuptools
import
setup
,
find_packages
version
=
'0.0.1.dev0'
name
=
'slapos.mypromise.html5as'
long_description
=
'A local promise for html5as'
setup
(
name
=
name
,
version
=
version
,
description
=
"Custom promise for SlapOS' HTML5AS"
,
long_description
=
long_description
,
long_description_content_type
=
'text/markdown'
,
maintainer
=
"Nexedi"
,
maintainer_email
=
"info@nexedi.com"
,
url
=
"https://lab.nexedi.com/nexedi/slapos"
,
packages
=
find_packages
(),
install_requires
=
[
'slapos.core'
,
],
zip_safe
=
True
,
test_suite
=
'test'
,
)
software/html5as/software.cfg
View file @
2c343a23
...
...
@@ -21,6 +21,8 @@ parts =
# Call creation of instance.cfg file that will be called for deployment of
# instance
template-cfg
# Install mypromise egg
mypromise
# Download instance.cfg.in (buildout profile used to deployment of instance),
# replace all {{ foo_bar }} parameters by real values
...
...
@@ -75,3 +77,27 @@ mode = 0644
[template_instance_replicate]
<= download-base
# Download and install the local promise egg
[mypromise-directory]
recipe = slapos.cookbook:mkdirectory
path = ${buildout:directory}/parts/mypromise
[download-promise-base]
<= download-base
url = ${:_profile_base_location_}/mypromise/${:_buildout_section_name_}
destination = ${mypromise-directory:path}/${:_buildout_section_name_}
[promise.py]
<= download-promise-base
[setup.py]
<= download-promise-base
[mypromise]
recipe = zc.recipe.egg:develop
egg = slapos.mypromise.html5as
setup = ${mypromise-directory:path}
depends =
${setup.py:destination}
${promise.py:destination}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment