Skip to content
This repository has been archived by the owner on May 26, 2018. It is now read-only.

Commit

Permalink
try to log and chmod but not working very well :(
Browse files Browse the repository at this point in the history
  • Loading branch information
ikit committed Oct 6, 2016
1 parent fc62c1b commit efad8a8
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions pirus/pirus_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,12 @@ def setup_logger(logger_name, log_file, level=logging.INFO):
def execute(cmd, olog, elog):
with subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) as proc:
# TODO FIXME => logging realtime not working :( ...
olog.info(proc.stdout.read())
elog.info(proc.stderr.read())
out = str(proc.stdout.read())
err = str(proc.stderr.read())
if out != "":
olog.info(out)
if err != "":
elog.info(err)



Expand Down Expand Up @@ -133,7 +137,7 @@ def run_pipeline(self, pipe_image_alias, config):
plog.info('WAITING | ' + str(len(lxd_client.containers.all())) + '/' + str(LXD_MAX) + ' containers -> ok to create a new one')
c_name = LXD_PREFIX + "-" + self.run_id
except:
plog.info('FAILLED | Unexpected error ' + sys.exc_info()[0])
plog.info('FAILLED | Unexpected error ' + str(sys.exc_info()[0]))
self.notify_status("FAILLED")
raise

Expand All @@ -154,7 +158,7 @@ def run_pipeline(self, pipe_image_alias, config):
# TODO => create symlink in ipath directory
# TODO => copy config file of the run in the ipath directory
except:
plog.info('FAILLED | Unexpected error ' + sys.exc_info()[0])
plog.info('FAILLED | Unexpected error ' + str(sys.exc_info()[0]))
self.notify_status("FAILLED")
raise

Expand All @@ -165,7 +169,7 @@ def run_pipeline(self, pipe_image_alias, config):
execute(["lxc", "start", c_name], olog, elog)
execute(["lxc", "exec", c_name, "/pipeline/run/run.sh"], olog, elog)
except:
plog.info('FAILLED | Unexpected error ' + sys.exc_info()[0])
plog.info('FAILLED | Unexpected error ' + str(sys.exc_info()[0]))
self.notify_status("FAILLED")
raise

Expand All @@ -175,15 +179,16 @@ def run_pipeline(self, pipe_image_alias, config):
try:
# Force the container to change results files owner to allow the server to use them
plog.info('STOP | - chown ' + str(os.getuid()) + ":" + str(os.getgid()) + ' on outputs and logs files produced by the container')
execute(["lxc", "exec", c_name, "--", "chown", str(os.getuid()) + ":" + str(os.getgid()), "-Rf", "/pipeline"])
execute(["useradd", "-u", str(os.getuid()), "-g", str(os.getgid()), "lxd"], olog, elog)
execute(["lxc", "exec", c_name, "--", "chown", str(os.getuid()) + ":" + str(os.getgid()), "-Rf", "/pipeline"], olog, elog)

plog.info('STOP | - chmod 775 on outputs and logs files produced by the container')
execute(["lxc", "exec", c_name, "--", "chmode", "775", "-Rf", "/pipeline"])
execute(["lxc", "exec", c_name, "--", "chmode", "775", "-Rf", "/pipeline"], olog, elog)

plog.info('STOP | - closing and deleting the lxc container : ' + c_name)
execute(["lxc", "delete", c_name, "--force"], olog, elog)
except:
plog.info('FAILLED | Unexpected error ' + sys.exc_info()[0])
plog.info('FAILLED | Unexpected error ' + str(sys.exc_info()[0]))
self.notify_status("FAILLED")
raise

Expand Down

0 comments on commit efad8a8

Please sign in to comment.