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

[Enhancement] Headless mode on Linux #56

Closed
PavelSkorynin opened this Issue Apr 30, 2018 · 6 comments

Comments

2 participants
@PavelSkorynin
Copy link

PavelSkorynin commented Apr 30, 2018

Hi,
thank you for great work! I have discovered your product a little time ago and totally falled in love it.
Building instructions can be successfully prepared on any platform using GUI. But I need command line tools to make building instructions from previously prepared *.ldr file.

The process I want to achive:

  1. Editor creates/modifies *.ldr model using LeoCAD or something else. He pushes changes into git repository.
  2. Publisher pulls *.ldr from the git repository and modifies it using LPub3D to make building instruction. He pushes changes into git repository too.
  3. CI runs docker image with LPub3D and exports building instruction as pdf. The result pdf file may be postprocessed (combined with other pdf files) and uploaded to the shared storage (Google Drive or Dropbox, for example).

With third step there is a problem. I cannot run LPub3D in command line mode to export building instruction. I have already docker image based on ubuntu_xenial with LPub3d 2.2.2, but all my tries to run LPub3D without GUI fail.

Please help to make it possible!
I'm also developer and can help to solve this request, if you guide me.

@trevorsandy trevorsandy self-assigned this May 1, 2018

@trevorsandy trevorsandy changed the title Command line mode for building instructions [Enhancement] Headless mode on Linux May 1, 2018

@trevorsandy

This comment has been minimized.

Copy link
Owner

trevorsandy commented May 1, 2018

What you are requesting is actually "headless" mode which by default requires command line execution.

LPub3D currently runs headless on Travis CI macOS and AppVeyor Windows images. However, image and document publishing commands are not implemented in version 2.2.2. This enhancement has been completed however (see [Enhancement] Enable console commands #12) and will be released in version 2.3.0 (next release).

I am not yet able to get it to run headless on Linux however, neither with Xvfb nor Qt's QT_QPA_PLATFORM=offscreen.

Here's my script to enable headless mode on Unix - macOS is OK, Linux is KO:

export DISPLAY=:99.0
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
  /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16
  # Set to address 'QXcbConnection: Could not connect to display' message
  sudo ln -s /usr/share/fonts /usr/lib/x86_64-linux-gnu/fonts
  export QT_QPA_PLATFORM=offscreen
  export QT_QPA_FONTDIR=/usr/lib/x86_64-linux-gnu/fonts
fi
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
  ( sudo Xvfb :99 -ac -screen 0 1024x768x24; echo ok ) &
fi
# give xvfb some time to start
sleep 3

Cheers,

@PavelSkorynin

This comment has been minimized.

Copy link

PavelSkorynin commented May 1, 2018

Thanks a lot for the answer!

I have tried to run LPub3D in headless mode on Ubuntu Xenial with Xvfb, but it fails too. Here is a log. Maybe it helps in your investigation.

user@555932a47e04:/$ xvfb-run --auto-servernum --server-num=1 -s "-screen 0 640x480x24" lpub3d22 -i image.png /shared/02x01.ldr 
LPub3D for Linux 64bit
==========================
Arguments: -i image.png /shared/02x01.ldr

--------------------------
LPub3D Application Folder....(lpub3d)
LPub3D App Data Path.........(/user/.local/share/LPub3D Software/lpub3d22)
LPub3D Executable Path.......(/usr/bin)
LPub3D Extras Resource Path..(/usr/share/lpub3d)
--------------------------

INFO void Application::initialize() @ln 307 "Initializing application..." 
INFO void Application::splashMsg(QString) @ln 72 "5% - Initializing application..." 
INFO void Application::splashMsg(QString) @ln 72 "10% - Locate LDraw archive libraries..." 
INFO void Application::splashMsg(QString) @ln 72 "10% - Locate LDraw directory..." 
INFO void Application::splashMsg(QString) @ln 72 "15% - Preferences loading..." 
INFO void Application::splashMsg(QString) @ln 72 "15% - Selecting update settings..." 
INFO void Application::splashMsg(QString) @ln 72 "20% - 3D Viewer window loading..." 
INFO void Application::splashMsg(QString) @ln 72 "25% - Viewer defaults loading..." 
INFO void Application::splashMsg(QString) @ln 72 "30% - LPub3D GUI window loading..." 
INFO void Application::splashMsg(QString) @ln 72 "35% - LPub3D window defaults loading..." 
INFO static Preferences::lgeoPreferences() @ln 1198 LGEO library status... 
INFO static Preferences::lgeoPreferences() @ln 1218 "LGEO library path  : Not found" 
INFO static Preferences::rendererPreferences(bool) @ln 1227 Image renderers... 
INFO static Preferences::rendererPreferences(bool) @ln 1267 "LDGLite : /opt/lpub3d/3rdParty/ldglite-1.3/bin/ldglite" 
INFO static Preferences::rendererPreferences(bool) @ln 1275 "LDView  : /opt/lpub3d/3rdParty/ldview-4.3/bin/ldview" 
INFO static Preferences::rendererPreferences(bool) @ln 1284 "POVRay  : /opt/lpub3d/3rdParty/lpub3d_trace_cui-3.8/bin/lpub3d_trace_cui" 
INFO static Preferences::rendererPreferences(bool) @ln 1370 Processing renderer configuration files... 
INFO static Preferences::setLDGLiteIniParams() @ln 1435 "LDGLite.ini file   : /user/.local/share/LPub3D Software/lpub3d22/3rdParty/ldglite-1.3/config/ldglite.ini" 
INFO static Preferences::updateLDViewIniFile(bool) @ln 1450 "LDView ini file    : /user/.local/share/LPub3D Software/lpub3d22/3rdParty/ldview-4.3/config/ldview.ini" 
INFO static Preferences::updateLDViewPOVIniFile(bool) @ln 1512 "LDViewPOV ini file : /user/.local/share/LPub3D Software/lpub3d22/3rdParty/ldview-4.3/config/ldviewPOV.ini" 
INFO static Preferences::updatePOVRayConfFile(bool) @ln 1582 "POVRay conf file  : /user/.local/share/LPub3D Software/lpub3d22/3rdParty/lpub3d_trace_cui-3.8/config/povray.conf" 
INFO static Preferences::updatePOVRayIniFile(bool) @ln 1670 "POVRay ini file    : /user/.local/share/LPub3D Software/lpub3d22/3rdParty/lpub3d_trace_cui-3.8/config/povray.ini" 
INFO static Preferences::rendererPreferences(bool) @ln 1385 "POVRay ini path    : /usr/share/lpub3d/3rdParty/lpub3d_trace_cui-3.8/resources/ini" 
INFO static Preferences::rendererPreferences(bool) @ln 1390 "POVRay include path: /usr/share/lpub3d/3rdParty/lpub3d_trace_cui-3.8/resources/include" 
INFO static Preferences::rendererPreferences(bool) @ln 1395 "POVRay scene path  : Not found" 
INFO void Application::splashMsg(QString) @ln 72 "40% - 3D Viewer initialization..." 
INFO void Application::splashMsg(QString) @ln 72 "45% - 3D Viewer widgets loading..." 
INFO void Application::splashMsg(QString) @ln 72 "50% - Search directory preferences loading..." 
INFO void PartWorker::ldsearchDirPreferences() @ln 96 "Fade Step is OFF." 
INFO void PartWorker::ldsearchDirPreferences() @ln 101 "Renderer is LDView" 
INFO static Preferences::setLDViewExtraSearchDirs(const QString&) @ln 2314 "Updating ExtraSearchDirs in /user/.local/share/LPub3D Software/lpub3d22/3rdParty/ldview-4.3/config/ldview.ini" 
INFO static Preferences::setLDViewExtraSearchDirs(const QString&) @ln 2336 ExtraSearchDirs OUT: Dir001=/user/ldraw/models 
INFO static Preferences::setLDViewExtraSearchDirs(const QString&) @ln 2314 "Updating ExtraSearchDirs in /user/.local/share/LPub3D Software/lpub3d22/3rdParty/ldview-4.3/config/ldviewPOV.ini" 
INFO static Preferences::setLDViewExtraSearchDirs(const QString&) @ln 2336 ExtraSearchDirs OUT: Dir001=/user/ldraw/models 
INFO bool PartWorker::processPartsArchive(const QStringList&, const QString&) @ln 931 Archive parts... 
INFO bool PartWorker::processPartsArchive(const QStringList&, const QString&) @ln 932 "Archiving search directory parts to /user/.local/share/LPub3D Software/lpub3d22/libraries/lpub3dldrawunf.zip." 
INFO void Application::splashMsg(QString) @ln 72 "60% - Archiving search directory parts..." 
INFO bool PartWorker::processPartsArchive(const QStringList&, const QString&) @ln 972 "Archived 0 parts from /user/ldraw/models" 
INFO bool PartWorker::processPartsArchive(const QStringList&, const QString&) @ln 1003 "Finished. No search directory parts archived. Unofficial library not reloaded." 
INFO void Application::splashMsg(QString) @ln 72 "70% - Finished archiving search directory parts." 
INFO void Application::splashMsg(QString) @ln 72 "80% - Archive libraries loading..." ```
@trevorsandy

This comment has been minimized.

Copy link
Owner

trevorsandy commented May 1, 2018

There is no error in this log. It shows a successful execution of LPub3D as far as version 2.2.2 is enabled.

As I mentioned in the previous post. Version 2.2.2 does not implement any usable instruction publishing console commands.

As you have attempted to run -i, a 3DViewer (LeoCAD) console command which is not enabled, the execution has halted at a dialogue window that you cannot see.

The only functioning console commands available in version 2.2.2 are the printing the command options (which, again, do not work in version 2.2.2), printing the LPub3D and 3DViewer version information and any command line flag starting with '-' that allows LPub3D to fully load but does not call any of the functions available in the command options output - the help and version calls do not allow LPub3D to load for obvious reasons.

So the command option '-i' will not run to completion in headless mode because processing an image is not enabled.

Try running '-foo' which should completely load LPub3D and return the message 'Unknown commandline parameter: -foo'

I could not get Xvfb to work on my Docker image the last time I tried. What does your Dockerfile look like ?

Cheers,

@PavelSkorynin

This comment has been minimized.

Copy link

PavelSkorynin commented May 1, 2018

I don't actually have a Dockerfile. Image is based on ubuntu:xenial composed with Docker-compose.yml as described here: https://github.com/trevorsandy/lpub3d/blob/master/builds/utilities/README.md
Then I start container, install lpub3d from generated deb package and run it with command you can see in the log above.

@trevorsandy

This comment has been minimized.

Copy link
Owner

trevorsandy commented May 1, 2018

Ok - You used my config which is good. It will match what I test here.

I was successful to get LPub3D to run headless on Linux using your Xvfb command – I was starting Xvfb as a background process before with works on macOS but appearently not on Linux.

Anyway, lookout for LPub3D version 2.3 which should satisfy your request.

Cheers,

@trevorsandy trevorsandy added this to the v2.2.3 milestone May 1, 2018

@PavelSkorynin

This comment has been minimized.

Copy link

PavelSkorynin commented May 1, 2018

Ok, thanks! Waiting for 2.3

@trevorsandy trevorsandy closed this May 1, 2018

@trevorsandy trevorsandy added this to DONE in LPub3D Next via automation May 1, 2018

@trevorsandy trevorsandy removed this from DONE in LPub3D Next Aug 5, 2018

@trevorsandy trevorsandy moved this from DONE to DEPLOYED in LPub3D Maintenance Sep 6, 2018

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