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

edgesense_drupal fails silently if run without login shell #101

Open
tanius opened this issue Apr 12, 2016 · 2 comments
Open

edgesense_drupal fails silently if run without login shell #101

tanius opened this issue Apr 12, 2016 · 2 comments

Comments

@tanius
Copy link
Member

tanius commented Apr 12, 2016

Currently, any method to call the edgesense_drupal script as a user without a login shell (means if the shell is set to /bin/nologin or /bin/false in /etc/passwd) fails:

  • It happens when ticking "Run During Cron" on the Script Configuration screen (/admin/edgesense/script-param) and then running the Drupal cron job under a user without login shell, such as with the following entry in /etc/cron.d/somefile:

    08 * * * * web1  drush @site-alias cron
    
  • It happens when calling the edgesense_drupal script directly in a cron job using a user without a login shell, such as with the following entry in /etc/cron.d/somefile:

    10 5 * * *  web1 edgesense_drupal /path/to/edgesense/script/run.json
    
  • It happens when running the edgesense_drupal command from above directly in a terminal, for example by executing (as root):

    su web1 -c "edgesense_drupal /path/to/edgesense/script/run.json"
    

All of these fail silently, without an error message on the screen or the Edgesense log. However they should not fail, since cron is normally able to run any command as users without login shells (see here – and it works fine with the web1 user in our deployment for other cron jobs).

When specifying a shell explicitly, the above command works successfully, confirming that the problem is the absence of a login shell (and not permission issues etc.):

su web1 --shell /bin/sh --command "edgesense_drupal /path/to/edgesense/script/run.json"
@tanius tanius changed the title edgesense_drupal fails silently if not run as root edgesense_drupal fails silently if run as user without a shell Apr 12, 2016
@luca
Copy link
Contributor

luca commented Apr 27, 2016

the edgesense_drupal program is a script created by python easyinstall / setuptools. It requires environment variables provided by a shell to be there (I think primarily the PATH variable).

The way to run it for a user without a login shell is to explicitly specify the shell on the command line (like you did), or if scheduled from cron is to use a line like:

08 * * * * web1 /bin/bash -l -c "edgesense_drupal /path/to/edgesense/script/run.json"

directly calling the shell.

Your first crontab example though is not running the edgesense_drupal script directly, but rather drush: I think that drush has the same limitation as edgesense_drupal in that it needs some environment that is not there when run for web1 without a login shell.
So to run drush you'll need to add this to the crontab:

08 * * * * web1 /bin/bash -l -c "drush @site-alias cron"

@tanius tanius changed the title edgesense_drupal fails silently if run as user without a shell edgesense_drupal fails silently if run without login shell Jul 8, 2016
@tanius
Copy link
Member Author

tanius commented Jul 8, 2016

Your last suggestion to run edgesense_drupal via /bin/bash -l -c "drush @site-alias cron" worked. The JSON files for nodes, users and comments are generated again now, and the network data package is generated from them. Of course, "Run during cron" has to be enabled on /admin/edgesense/script-param for this to work.

Note that drush cron itself does not need a login shell to run successfully (we always used it without one), just to execute edgesense_drupal.

The cleanest resolution (if getting rid of these special requirements completely is not possible) is probably to find out what environment variables edgesense_drupal needs, and to add them to the top of the crontab file or to prepend them before the drush cron command.

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

No branches or pull requests

2 participants