Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No log file on error #2

Open
Tyil opened this issue May 7, 2018 · 13 comments
Open

No log file on error #2

Tyil opened this issue May 7, 2018 · 13 comments

Comments

@Tyil
Copy link

Tyil commented May 7, 2018

I'm trying to start a service with service-start, which fails on my OS (Funtoo) because it uses rc-service, not service. I've found this out by looking through the source code, because the log file it should create doesnt exist:

@ linux service manager
bash hook error: do_bash_hook failed.
 see /opt/sparrow/tmp/19834/story-0/649.err for details at /usr/local/lib64/perl5/5.24.0/Outthentic/Story.pm line 655.
STATUS  FAILED (2)
failed to execute shell command: cd /opt/sparrow/plugins/public/service && export PATH=$PATH:$PWD/local/bin && export PERL5LIB=$PWD/local/lib/perl5:$PERL5LIB && export PYTHONPATH=$PWD/python-lib:$PYTHONPATH &&   strun --root ./ --task '[task] start service dnsmasq' --json /opt/sparrow/cache/task_5.json --purge-cache --format default at /usr/local/lib64/perl5/5.24.0/Sparrow/Misc.pm line 32.
        Sparrow::Misc::execute_shell_command("cd /opt/sparrow/plugins/public/service \x{26}\x{26} export PATH=\$PATH:\$"...) called at /usr/local/lib64/perl5/5.24.0/Sparrow/Commands/Task.pm line 364
        Sparrow::Commands::Task::task_run("taskbox", "start-service-dnsmasq", "--no-exec", "--json", "/opt/sparrow/cache/task_5.json", "--purge-cache", undef) called at /usr/local/lib64/perl5/5.24.0/Sparrow/Commands/TaskBox.pm line 89
        Sparrow::Commands::TaskBox::box_run("/opt/sparrow/sparrow-cache/task-box.json", "--mode", "quiet", "--purge-cache") called at /usr/local/bin/sparrow line 237
The spawned command 'sudo sh -c 'export LC_ALL=C ; export GIT_PROTOCOL=https ; export PERL_USE_UNSAFE_INC=1 ; export PATH=/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/local/bin:/usr/sbin/:/sbin/:/bin/:$PATH ; export SPARROW_ROOT=/opt/sparrow ; export SPARROW_CONF_PATH=/opt/sparrow/sparrow-cache/sparrow.yaml ; export OUTTHENTIC_FORMAT=default ; sparrow box run /opt/sparrow/sparrow-cache/task-box.json --mode quiet --purge-cache'' exited unsuccessfully (exit code: 2)
  in block <unit> at /home/tyil/.rakudo-star/rakudo-star-2018.04/install/share/perl6/site/resources/EF69F25AAEC473A77D51F9650464FD62B1520AC1 line 396
  in sub MAIN at /home/tyil/.rakudo-star/rakudo-star-2018.04/install/share/perl6/site/bin/sparrowdo line 2
  in block <unit> at /home/tyil/.rakudo-star/rakudo-star-2018.04/install/share/perl6/site/bin/sparrowdo line 2
$ cat /opt/sparrow/tmp/19834/story-0/649.err
cat: /opt/sparrow/tmp/19834/story-0/649.err: No such file or directory

I'm also trying to fix the issue on my machine, but it still errors out, and since there's no log file I can't really troubleshoot at this point. Why is there no error log at the path noted in the output of sparrowdo?

@melezhik melezhik self-assigned this May 7, 2018
@Tyil
Copy link
Author

Tyil commented May 7, 2018

FWIW, this is the last part of a tutorial I'm writing on how to get started with Sparrowdo, including some sample code to set up a DNS cache with dnsmasq. This tutorial in turn intends to close https://github.com/melezhik/sparrowdo/issues/24.

@melezhik
Copy link
Owner

melezhik commented May 7, 2018

Hi Patrick! Sparrowdo runs sparrow client with --purge-cache option enabled, that results in cleanup of all temp/cache files upon sparrow run. Here is 67f6533bee4c5ef702c5201d6ab09e574c23c894 fix to make it possible overwrite this option on sparrowdo side, I will want to like that:

sparrowdo --purge_cache=False

Please let me know if it helps.

Alexey

@melezhik
Copy link
Owner

melezhik commented May 7, 2018

Here if full link -melezhik/sparrowdo@67f6533

@melezhik
Copy link
Owner

melezhik commented May 7, 2018

Probably I need to dynamically disable cache purge in case of any errors during sparrow client execution, so that a use could take troubleshooting, but this require changes in Sparrow client, meanwhile please use sparrowdo --purge_cache=False as a work around ....

@Tyil
Copy link
Author

Tyil commented May 7, 2018

With that patch the error log does exist, but it's empty.

@melezhik
Copy link
Owner

melezhik commented May 7, 2018

Please run as sparrwodo --verbose --purge_cache=False and attach output ... I will take a look closer ...

@melezhik
Copy link
Owner

melezhik commented May 7, 2018

Ok, no need to attach the log, I know the reason:


$ cat hook.bash

service=$(config service)

shopt -s nocasematch;

if [[ $os =~ "debian" ]]; then
  run_story $(config action) os debian service $service
elif [[ "$os" =~ "ubuntu" ]]; then
  run_story $(config action) os debian service $service
elif [[ "$os" =~ "amazon" ]]; then
  run_story $(config action) os amazon service $service
elif [[ "$os" =~ "centos" ]]; then
  run_story $(config action) os $os service $service
elif [[ "$os" =~ "archlinux" ]]; then
  run_story $(config action) os $os service $service
elif [[ "$os" =~ "minoca" ]]; then
  run_story $(config action) os $os service $service
else
  echo "unknown os: $os"
  exit 1
fi

Obviously funtoo is not listed here, so Sparrow just print "unknown os: funtoo" into STDOUT and just exit with 1

The reason you can't see anything in the STDOUT is a Sparrow specific how it, handles errors in so called hooks files. ( The is a probably subject for another improvement ticket ),

I will fix you up with patch soon.

melezhik added a commit that referenced this issue May 7, 2018
@melezhik
Copy link
Owner

melezhik commented May 7, 2018

I've released to SPH a new version of service plugin with Funtoo support - https://sparrowhub.org/info/service?v=0.002000

Please you this one and make sure that sparrow client index is updated on remote host ( this is default mode unless you don't use --no_index_update)

@Tyil
Copy link
Author

Tyil commented May 7, 2018

Oh, I completely missed that part, I was looking in the modules/start/story.bash file, and just updated that one in the hopes that'd work. I can rewrite that file to a case and see if I can fix it like that. As an added bonus, we'll get some cleaner code out of it. I'll probably add a default case to try the Debian version, but add in a warning about it.

@Tyil
Copy link
Author

Tyil commented May 7, 2018

I'll try to update to your new version for now, and update it if I think it can be made prettier :)

@melezhik
Copy link
Owner

melezhik commented May 7, 2018

Sure, it's open source )))))

@Tyil
Copy link
Author

Tyil commented May 7, 2018

The new version you uploaded works to call the rc-service tool correctly! Thanks for the quick update!

@melezhik
Copy link
Owner

melezhik commented May 7, 2018

Yeah, sure. It's was "blind" change but I have been found lucky )))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants