0

I'm having an odd issue with Greenscript (1.2.6l) in Heroku using Play 1.2.3 for Java.

Locally, using the Play launcher or Foreman start, in both modes (DEV and PROD) Greenscript works fine, compresses files and loads the css/javascript.

In Heroku I get this:

2011-11-28T19:18:34+00:00 heroku[router]: GET XXXXXX.herokuapp.com/public/gs/b097436f-9941-4d07-98cf-31bd574e6351.js dyno=web.1 queue=0 wait=0ms service=26ms status=404 bytes=4222

As you can see, a 404 error when trying to load a compressed js file. This error happens setting Greenscript to work with file-system or in-memory storage of files.

Anyone has had a similar issue and knows the solution? Or, if not, can anyone propose an alternative for Greenscript?

Pere Villega
  • 16,429
  • 5
  • 63
  • 100
  • Do you have a simple test case / demo you can point me to so I can try this on my own? – James Ward Nov 28 '11 at 20:24
  • @James Ward Request #36314 at Heroku (I see you work in there), you should have access to the code. I'm checking Press plugin in the meantime as an alternative (locally by now) – Pere Villega Nov 28 '11 at 21:39

3 Answers3

1

I was using the plugin and though is pretty cool it slows down loading of pages in development mode considerably. Icing on the cake was the bug in 1.2.6k causing the cache to be cleared.

Check the html source code, if you don't see the reference to js/css files is the same issue!

I am now using a custom script ant that unzip the war file, removes all the stuff that should not be there ( everything gets included in the current play war command ) and compresses the javascript files with names not ending in min.js

This way when I code I can still see the javascript but is compressed in production.

I am using less for the css but for that I manually run the lessc compiler. It does not change so much after all so I'm not too bothered with that.

This is what the script targets look like

<target name="minimize-war" depends="" description="removes not needed stuff from war file">
    <delete dir="${buildDir}/tmp"/>
    <unzip src="${buildDir}/myappname-war.war" dest="${buildDir}/tmp"/>
    <foreach target="minimize" param="filename">
            <fileset dir="${buildDir}/tmp/WEB-INF/application/public/javascripts" >
                    <include name="**/*.js"/>
                    <exclude name="**/*.min.js"/>
            </fileset>
            <param name="type" value="js"/>
    </foreach>
    <foreach target="minimize" param="filename">
            <fileset dir="${buildDir}/tmp/WEB-INF/application/public/stylesheets" >
                    <include name="**/*.css"/>
            </fileset>
            <param name="type" value="css"/>
    </foreach>
    <delete dir="${buildDir}/tmp/WEB-INF/application/ant-lib"/>
    <delete dir="${buildDir}/tmp/WEB-INF/application/docs"/>
    <delete dir="${buildDir}/tmp/WEB-INF/application/eclipse"/>
    <delete dir="${buildDir}/tmp/WEB-INF/application/liquibase"/>
    <delete dir="${buildDir}/tmp/WEB-INF/application/icon-lib"/>
    <delete dir="${buildDir}/tmp/WEB-INF/application/test"/>
    <delete dir="${buildDir}/tmp/WEB-INF/application/test-result"/>
    <delete><fileset dir="${buildDir}/tmp/WEB-INF/application" includes="*.*"></fileset></delete>
    <delete file="${buildDir}/myappname-war.war"/>
    <zip destfile="${buildDir}/myappname-war.war" basedir="${buildDir}/tmp"/>
</target>

<target name="minimize">
    <echo>Running compress for type ${type} on file ${filename} </echo>
    <java dir="${buildDir}/tmp/WEB-INF/application/public/javascripts" jar="${basedir}/ant-lib/yuicompressor-2.4.6.jar" fork="true">
            <arg value="--charset" />
            <arg value="UTF-8" />
            <arg line="--type ${type} -o ${filename} ${filename}" />
    </java>
</target>
mericano1
  • 2,914
  • 1
  • 18
  • 25
  • Well, deployment in Heroku uses Play server, not war, so your solution doesn't really apply. Thanks for the information anyway. – Pere Villega Nov 29 '11 at 19:55
1

If you are running on a cluster, then there will be an issue. Checkout https://github.com/greenlaw110/greenscript/issues/30

Gelin Luo
  • 14,035
  • 27
  • 86
  • 139
0

After some testing it seems there is an issue with Greenscript up to the current version (1.2.6m) which makes it fail in Heroku.

I used a workaround (Press plugin for Play) which still fails in Memory mode, but works using the filesystem. If any of you uses Heroku and is having problems, I would recommend this as a solution while Greenscript gets fixed.

Pere Villega
  • 16,429
  • 5
  • 63
  • 100