Commit 7ead3646 authored by Jérome Perrin's avatar Jérome Perrin

slaprunner: provide pidfile in config file for slapos node

Thanks to !158 , in a slaprunner we can use slapos command:
```
$ slapos supply https://lab.nexedi.com/nexedi/slapos/raw/1.0.19/software/erp5/software.cfg slaprunner
```
works fine to supply a software to "current" webrunner, but building this software with `slapos node software` fails with:
```
$ slapos node software
2017-10-03 02:46:33 slapos[29536] CRITICAL slapgrid could not write pidfile /opt/slapos/slapgrid-sr.pid
2017-10-03 02:46:33 slapos[29536] ERROR [Errno 13] Permission denied: '/opt/slapos/slapgrid-sr.pid'
Traceback (most recent call last):
  File "/opt/slapgrid/f496eadc03f1ac5a0ab1e4ae60bbe972/eggs/slapos.core-1.4.1-py2.7.egg/slapos/cli/entry.py", line 300, in run_subcommand
    result = cmd.run(parsed_args)
  File "/opt/slapgrid/f496eadc03f1ac5a0ab1e4ae60bbe972/eggs/slapos.core-1.4.1-py2.7.egg/slapos/cli/command.py", line 50, in run
    return self.take_action(parsed_args)
  File "/opt/slapgrid/f496eadc03f1ac5a0ab1e4ae60bbe972/eggs/slapos.core-1.4.1-py2.7.egg/slapos/cli/slapgrid.py", line 116, in take_action
    setRunning(logger=self.app.log, pidfile=pidfile)
  File "/opt/slapgrid/f496eadc03f1ac5a0ab1e4ae60bbe972/eggs/slapos.core-1.4.1-py2.7.egg/slapos/grid/utils.py", line 155, in setRunning
    write_pid(logger, pidfile)
  File "/opt/slapgrid/f496eadc03f1ac5a0ab1e4ae60bbe972/eggs/slapos.core-1.4.1-py2.7.egg/slapos/grid/utils.py", line 167, in write_pid
    with open(pidfile, 'w') as fout:
IOError: [Errno 13] Permission denied: '/opt/slapos/slapgrid-sr.pid'
```

because slaprunner's web interface also runs software, it's better both `slapos node software` command and the one from slaprunner web interface uses the same pid file so that they do not run in parallel.

This depends on slapos.core!29

/reviewed-on !235
parents 0ce9ba5d 4b84ad9e
...@@ -19,11 +19,11 @@ md5sum = 713db528880282d568278f09458d2aab ...@@ -19,11 +19,11 @@ md5sum = 713db528880282d568278f09458d2aab
[template-runner] [template-runner]
filename = instance-runner.cfg filename = instance-runner.cfg
md5sum = baf70a9f2f433ea0f2f5139700e53b1f md5sum = 7df86928aeef0fbada832b0283b9a454
[template-runner-import-script] [template-runner-import-script]
filename = template/runner-import.sh.jinja2 filename = template/runner-import.sh.jinja2
md5sum = 130193114cbbcd014af9704851410605 md5sum = 1edd9c7a20e208b6cb647886bfb6d1bb
[instance-runner-import] [instance-runner-import]
filename = instance-runner-import.cfg.in filename = instance-runner-import.cfg.in
...@@ -55,7 +55,7 @@ md5sum = 525e37ea8b2acf6209869999b15071a6 ...@@ -55,7 +55,7 @@ md5sum = 525e37ea8b2acf6209869999b15071a6
[template-slapos-cfg] [template-slapos-cfg]
filename = template/slapos.cfg.in filename = template/slapos.cfg.in
md5sum = ef16446d432e1397182b1654fe920ffb md5sum = 035e027e9cb9bbdca0509ac895fc4696
[template-parameters] [template-parameters]
filename = parameters.xml.in filename = parameters.xml.in
......
...@@ -137,6 +137,8 @@ working-directory = $${runnerdirectory:home} ...@@ -137,6 +137,8 @@ working-directory = $${runnerdirectory:home}
project-directory = $${runnerdirectory:project} project-directory = $${runnerdirectory:project}
instance_root = $${runnerdirectory:instance-root} instance_root = $${runnerdirectory:instance-root}
software_root = $${runnerdirectory:software-root} software_root = $${runnerdirectory:software-root}
pidfile-software = $${directory:run}/slapgrid-cp.pid
pidfile-instance = $${directory:run}/slapgrid-sr.pid
ssh_client = ${openssh:location}/bin/ssh ssh_client = ${openssh:location}/bin/ssh
public_key = $${runner-sshd-raw-server:rsa-keyfile}.pub public_key = $${runner-sshd-raw-server:rsa-keyfile}.pub
private_key = $${runner-sshd-raw-server:rsa-keyfile} private_key = $${runner-sshd-raw-server:rsa-keyfile}
...@@ -728,14 +730,12 @@ ip = $${slaprunner:ipv4} ...@@ -728,14 +730,12 @@ ip = $${slaprunner:ipv4}
server = $${:ip}:$${:port} server = $${:ip}:$${:port}
port = 39986 port = 39986
slapgrid-cp = slapgrid-cp slapgrid-cp = slapgrid-cp
slapgrid-cp-command = $${slaprunner:slapos} node instance --all --cfg $${:slapos-cfg} --pidfile $${:slapgrid-cp-pid} --verbose --logfile $${:slapgrid-cp-log} slapgrid-cp-command = $${slaprunner:slapos} node instance --all --cfg $${:slapos-cfg} --verbose --logfile $${:slapgrid-cp-log}
slapgrid-cp-log = $${runnerdirectory:home}/instance.log slapgrid-cp-log = $${runnerdirectory:home}/instance.log
slapgrid-cp-pid = $${directory:run}/slapgrid-cp.pid
slapgrid-cp-startretries = 0 slapgrid-cp-startretries = 0
slapgrid-sr = slapgrid-sr slapgrid-sr = slapgrid-sr
slapgrid-sr-command = $${slaprunner:slapos} node software --all --cfg $${:slapos-cfg} --pidfile $${:slapgrid-sr-pid} --verbose --logfile $${:slapgrid-sr-log} slapgrid-sr-command = $${slaprunner:slapos} node software --all --cfg $${:slapos-cfg} --verbose --logfile $${:slapgrid-sr-log}
slapgrid-sr-log = $${runnerdirectory:home}/software.log slapgrid-sr-log = $${runnerdirectory:home}/software.log
slapgrid-sr-pid = $${directory:run}/slapgrid-sr.pid
slapgrid-sr-startretries = 0 slapgrid-sr-startretries = 0
slapproxy = slapproxy slapproxy = slapproxy
slapproxy-autorestart = true slapproxy-autorestart = true
......
...@@ -155,22 +155,20 @@ rm '{{ instance_folder }}'/etc/supervisord.conf.d/* || true ...@@ -155,22 +155,20 @@ rm '{{ instance_folder }}'/etc/supervisord.conf.d/* || true
SLAPOSCFG='{{ supervisord["slapos-cfg"] }}' SLAPOSCFG='{{ supervisord["slapos-cfg"] }}'
SLAPGRIDSRLOG='{{ supervisord["slapgrid-sr-log"] }}' SLAPGRIDSRLOG='{{ supervisord["slapgrid-sr-log"] }}'
SLAPGRIDSRPID='{{ supervisord["slapgrid-sr-pid"] }}'
SLAPGRIDCPLOG='{{ supervisord["slapgrid-cp-log"] }}' SLAPGRIDCPLOG='{{ supervisord["slapgrid-cp-log"] }}'
SLAPGRIDCPPID='{{ supervisord["slapgrid-cp-pid"] }}'
log_message "Building newest Software Release..." log_message "Building newest Software Release..."
"$SLAPOS" node software --cfg "$SLAPOSCFG" --all --master-url="$MASTERURL" --logfile "$SLAPGRIDSRLOG" --pidfile "$SLAPGRIDSRPID" >/dev/null 2>&1 || "$SLAPOS" node software --cfg "$SLAPOSCFG" --all --master-url="$MASTERURL" --logfile "$SLAPGRIDSRLOG" >/dev/null 2>&1 ||
"$SLAPOS" node software --cfg "$SLAPOSCFG" --all --master-url="$MASTERURL" --logfile "$SLAPGRIDSRLOG" --pidfile "$SLAPGRIDSRPID" >/dev/null 2>&1 || "$SLAPOS" node software --cfg "$SLAPOSCFG" --all --master-url="$MASTERURL" --logfile "$SLAPGRIDSRLOG" >/dev/null 2>&1 ||
"$SLAPOS" node software --cfg "$SLAPOSCFG" --all --master-url="$MASTERURL" --logfile "$SLAPGRIDSRLOG" --pidfile "$SLAPGRIDSRPID" >/dev/null 2>&1 || "$SLAPOS" node software --cfg "$SLAPOSCFG" --all --master-url="$MASTERURL" --logfile "$SLAPGRIDSRLOG" >/dev/null 2>&1 ||
(tail -n 200 "$SLAPGRIDSRLOG" && false) (tail -n 200 "$SLAPGRIDSRLOG" && false)
# Remove defined scripts to force buildout to recreate them to have updated paths # Remove defined scripts to force buildout to recreate them to have updated paths
rm "$srv_directory"/runner/instance/slappart*/srv/runner-import-restore || true rm "$srv_directory"/runner/instance/slappart*/srv/runner-import-restore || true
log_message "Fixing Instances as needed after import..." log_message "Fixing Instances as needed after import..."
# XXX hardcoded # XXX hardcoded
"$SLAPOS" node instance --cfg "$SLAPOSCFG" --master-url=$MASTERURL --logfile "$SLAPGRIDCPLOG" --pidfile "$SLAPGRIDCPPID" >/dev/null 2>&1 || "$SLAPOS" node instance --cfg "$SLAPOSCFG" --master-url=$MASTERURL --logfile "$SLAPGRIDCPLOG" >/dev/null 2>&1 ||
"$SLAPOS" node instance --cfg "$SLAPOSCFG" --master-url=$MASTERURL --logfile "$SLAPGRIDCPLOG" --pidfile "$SLAPGRIDCPPID" >/dev/null 2>&1 || "$SLAPOS" node instance --cfg "$SLAPOSCFG" --master-url=$MASTERURL --logfile "$SLAPGRIDCPLOG" >/dev/null 2>&1 ||
"$SLAPOS" node instance --cfg "$SLAPOSCFG" --master-url=$MASTERURL --logfile "$SLAPGRIDCPLOG" --pidfile "$SLAPGRIDCPPID" >/dev/null 2>&1 || "$SLAPOS" node instance --cfg "$SLAPOSCFG" --master-url=$MASTERURL --logfile "$SLAPGRIDCPLOG" >/dev/null 2>&1 ||
(tail -n 200 "$SLAPGRIDCPLOG" && false) (tail -n 200 "$SLAPGRIDCPLOG" && false)
# Invoke defined scripts for each partition inside of slaprunner # Invoke defined scripts for each partition inside of slaprunner
......
...@@ -6,6 +6,8 @@ computer_id = slaprunner ...@@ -6,6 +6,8 @@ computer_id = slaprunner
maximal_delay = 0 maximal_delay = 0
root_check = {{ slaprunner['root_check'] }} root_check = {{ slaprunner['root_check'] }}
forbid_supervisord_automatic_launch = true forbid_supervisord_automatic_launch = true
pidfile_software = {{slaprunner['pidfile-software']}}
pidfile_instance = {{slaprunner['pidfile-instance']}}
[slapformat] [slapformat]
partition_amount = {{ slaprunner['partition-amount'] }} partition_amount = {{ slaprunner['partition-amount'] }}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment