Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
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
Carlos Ramos Carreño
slapos.core
Commits
48c8aef7
Commit
48c8aef7
authored
Jan 20, 2021
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP: standalone: include a service to run slapos node in a loop
parent
95822709
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
1 deletion
+34
-1
slapos/slap/standalone.py
slapos/slap/standalone.py
+34
-1
No files found.
slapos/slap/standalone.py
View file @
48c8aef7
...
...
@@ -231,6 +231,25 @@ class SlapOSCommandWriter(ConfigWriter):
os
.
chmod
(
path
,
0o755
)
class
SlapOSNodeServiceWriter
(
ConfigWriter
):
"""Write a bin/slapos-node-service wrapper.
"""
def
writeConfig
(
self
,
path
):
with
open
(
path
,
'w'
)
as
f
:
f
.
write
(
textwrap
.
dedent
(
"""
\
#!/bin/sh
while true
do
supervisorctl start slapos-node-software &
supervisorctl start slapos-node-instance &
supervisorctl start slapos-node-report &
sleep 60
done
"""
).
format
(
**
locals
()))
os
.
chmod
(
path
,
0o755
)
class
PartitionForwardConfiguration
(
object
):
"""Specification of request forwarding to another master, requested as user.
"""
...
...
@@ -293,8 +312,9 @@ class StandaloneSlapOS(object):
instance_root
=
None
,
shared_part_root
=
None
,
partition_forward_configuration
=
(),
auto_run
=
False
,
):
# type: (str, str, int, str, Iterable[str], Optional[str], Optional[str], Optional[str], Iterable[Union[PartitionForwardConfiguration, PartitionForwardAsPartitionConfiguration]]) -> None
# type: (str, str, int, str, Iterable[str], Optional[str], Optional[str], Optional[str], Iterable[Union[PartitionForwardConfiguration, PartitionForwardAsPartitionConfiguration]]
, bool
) -> None
"""Constructor, creates a standalone slapos in `base_directory`.
Arguments:
...
...
@@ -306,6 +326,7 @@ class StandaloneSlapOS(object):
* `instance_root` -- directory to create instances, default to "inst" in `base_directory`
* `shared_part_root` -- directory to hold shared parts software, default to "shared" in `base_directory`.
* `partition_forward_configuration` -- configuration of partition request forwarding to external SlapOS master.
* `auto_run` -- run slapos node in a loop to provision software and deploy instances automatically.
Error cases:
* `PathTooDeepError` when `base_directory` is too deep. Because of limitation
...
...
@@ -345,6 +366,11 @@ class StandaloneSlapOS(object):
'slapos node report --cfg {self._slapos_config} {debug_args}'
,
'stdout_logfile'
:
'{self._log_directory}/slapos-node-report.log'
,
},
'slapos-node-service'
:
{
'command'
:
'{self._slapos_node_service_bin}'
,
'stdout_logfile'
:
'{self._log_directory}/slapos-node-service.log'
,
}
}
self
.
_computer_id
=
computer_id
...
...
@@ -352,6 +378,11 @@ class StandaloneSlapOS(object):
self
.
_slap
.
initializeConnection
(
self
.
_master_url
)
self
.
_initBaseDirectory
(
software_root
,
instance_root
,
shared_part_root
)
if
auto_run
:
command
=
'slapos-node-service'
with
self
.
system_supervisor_rpc
as
supervisor
:
self
.
_logger
.
info
(
"starting command %s"
,
command
)
supervisor
.
startProcess
(
command
,
False
)
def
_initBaseDirectory
(
self
,
software_root
,
instance_root
,
shared_part_root
):
"""Create the directory after checking it's not too deep.
...
...
@@ -396,6 +427,7 @@ class StandaloneSlapOS(object):
ensureDirectoryExists
(
bin_directory
)
self
.
_slapos_bin
=
os
.
path
.
join
(
bin_directory
,
'slapos'
)
self
.
_slapos_node_service_bin
=
os
.
path
.
join
(
bin_directory
,
'slapos-node-service'
)
self
.
_log_directory
=
os
.
path
.
join
(
var_directory
,
'log'
)
ensureDirectoryExists
(
self
.
_log_directory
)
...
...
@@ -413,6 +445,7 @@ class StandaloneSlapOS(object):
SupervisorConfigWriter
(
self
).
writeConfig
(
self
.
_supervisor_config
)
SlapOSConfigWriter
(
self
).
writeConfig
(
self
.
_slapos_config
)
SlapOSCommandWriter
(
self
).
writeConfig
(
self
.
_slapos_bin
)
SlapOSNodeServiceWriter
(
self
).
writeConfig
(
self
.
_slapos_node_service_bin
)
self
.
start
()
...
...
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