HighCharts Export Server not creating image - highcharts

I have installed phantomjs (using npm -g option) and copied the relevent highchart files down from the github directory. Here's what the directory listing looks like - i chmod/chown'd everything to be wide open in case that was the problem
drwxrwxrwx 2 www-data www-data 4096 2013-08-30 15:01 ./
drwxr-xr-x 9 root root 4096 2013-08-29 18:11 ../
-rwxrwxrwx 1 www-data www-data 183 2013-08-30 13:43 callback.js*
-rwxrwxrwx 1 www-data www-data 4436 2013-08-30 13:34 data.js*
-rwxrwxrwx 1 www-data www-data 15464 2013-08-30 13:34 highcharts-convert.js*
-rwxrwxrwx 1 www-data www-data 139290 2013-08-30 13:34 highcharts.js*
-rwxrwxrwx 1 www-data www-data 21781 2013-08-30 13:34 highcharts-more.js*
-rwxrwxrwx 1 www-data www-data 173186 2013-08-30 13:34 highstock.js*
-rwxrwxrwx 1 www-data www-data 92629 2013-08-30 13:34 jquery.1.9.1.min.js*
-rwxrwxrwx 1 www-data www-data 223 2013-08-30 13:55 options1.json*
-rwxrwxrwx 1 www-data www-data 3249 2013-08-30 13:34 readme.md*
Command line works as expected:
phantomjs highcharts-convert.js -infile options1.json -outfile chart1.png -scale 2.5 -width 300 -constr Chart -callback
Creates chart1.png - and it looks like I would expect. I am able to start the webserver using this command
phantomjs highcharts-convert.js -host 0.0.0.0 -port 8080
OK, PhantomJS is ready.
I have created a short js to send post data
var p ={"infile":"{xAxis: {categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']},series: [{data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]}]};","outfile":"test1.png","constr":"Chart"}
console.log('success');
data=JSON.stringify(p);
$.ajax({
type: 'POST',
data: data,
url: 'http://myip:8080',
success: function(data) {
console.log('success');
}
});
This returns a 200 code but no data is returned to the browser. I have uncommented the line 107 in highcharts-convert.js = console.log(msg);
So I get this output
Highcharts.options.parsed
Highcharts.customCode.parsed
Highcharts.images.loaded
but no image that i can find. Thoughts?
Edit
Curl is working
curl -H "Content-Type: application/json" -X POST -d '{"infile":"{xAxis: {},series: [{data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]}]};","constr":"Chart","outfile":"/var/www/node/image/chart.png"}' 127.0.0.1:8080
except that I get a base64 string instead of the script saving the image. I got parts o the curl from here: http://www.highcharts.com/component/content/article/2-news/56-improved-image-export-with-phantomjs

The highcharts-convert.js script has undergone some changes. When specifying the outfile parameter while running the script in servermode, will create a file on the server. The script returns the file location on the server. This can be send to the client, so an download can be triggered from the client.
The above is facilitated by the Java highcharts export-server with the async parameter.
read more here
I thought this might be an alternative solution

PhantomJS can make a image and save it locally, but it doesn't support file download. That's why it's returning a 64 string representation of an image instead.

I went with the php/batik solution instead, I would still like to get this solution working in the future.
Note, the downloads to batik listed in the tutorial
http://xmlgraphics.apache.org/batik/#download
http://xmlgraphics.apache.org/batik/download.cgi
Leads to a 403 page, maybe consider linking somewhere else? I used a google cache for the page.

Related

Docker Swarm - Secrets problem when creating new container

i am running Production Docker Swarm Cluster with 3 manager nodes and many workers.
Every node (managers, worker) running same Docker and BTRFS Version:
Server Version: 17.12.1-ce
Storage Driver: btrfs
Build Version: Btrfs v4.9.1
Library Version: 102
I got deployed service with 1 replication. This service using secret.
"Secrets": [
{
"File": {
"Name": "/var/secret",
"UID": "0",
"GID": "0",
"Mode": 400
},
"SecretID": "vb8485hcixfhnqrp29m8lrfm2",
"SecretName": "supersecret"
}
This secret exists on Docker Swarm manager Leader:
{
"ID": "vb8485hcixfhnqrp29m8lrfm2",
"Version": {
"Index": 124153
},
"CreatedAt": "2020-08-17T12:22:29.656205519Z",
"UpdatedAt": "2020-08-17T12:22:29.656205519Z",
"Spec": {
"Name": "supersecret",
"Labels": {}
}
}
But cannot start container from this service. When i'm trying to update this service with "docker sevice update --force ${service_name}" always got exited container with Error:
Error response from daemon: unable to get secret from secret store: secret vb8485hcixfhnqrp29m8lrfm2 not found.
Container is creater without "secrets" folder in /var/lib/docker/container_ID/
drwx------. 1 root root 0 Aug 19 11:06 checkpoints
-rw-------. 1 root root 9305 Aug 19 11:41 config.v2.json
-rw-r--r--. 1 root root 1599 Aug 19 11:41 hostconfig.json
-rw-r--r--. 1 root root 13 Aug 19 11:41 hostname
-rw-r--r--. 1 root root 150 Aug 19 11:41 hosts
-rw-r--r--. 1 root root 48 Aug 19 11:41 resolv.conf
-rw-r--r--. 1 root root 71 Aug 19 11:41 resolv.conf.hash
drwx------. 1 root root 0 Aug 19 11:06 shm
I dont know what to do or what's wrong. Your help will be much appreciated.
As a response to
Did you try to reference the secret by its name instead of its id? Honestly, I never even though about referencing secrets by its randomly generated id, when there is a stable self declared name. – Metin
as per Docker API dopcumentation:
SecretName is the name of the secret that this references, but this is
just provided for lookup/display purposes. The secret in the reference
will be identified by its ID.
Which means that adressing the secret under it's name likely won't solve the problem. Im starting to suspect, that this error message doesn't describe what is actually happening (or at least not fully).

devcontainer, how to make X display work (mount graphics inside docker in visual studio code)

Normally I use this trick to make X work inside docker:
docker run --rm -it -v /tmp/.X11-unix:/tmp/.X11-unix -v $HOME/Videos:/videos -e DISPLAY=unix$DISPLAY --name knl kdenlive
I tried doing the same on a devcontainer:
{
"name": "example_dockerized_environment",
"dockerFile": "Dockerfile",
"extensions": [
"ms-vscode.cpptools",
"twxs.cmake",
"eamodio.gitlens"
],
"mounts": [ "source=../,target=/home/project", "source=/tmp/.X11-unix, target=/tmp/.X11-unix"],
"containerEnv": {
"DISPLAY": "unix:0"
},
"runArgs": ["--privileged"]
}
As you can see, I passed unix$DISPLAY and also mounted X11-unix
But I get
root#5e6a10efbea6:/workspaces/leuze_lidar_volume/sdk/quanergy_client-master# ./visualizer --host localhost
ERROR: In /build/vtk6-YpT4yb/vtk6-6.2.0+dfsg1/Rendering/OpenGL/vtkXOpenGLRenderWindow.cxx, line 1466
vtkXOpenGLRenderWindow (0x2293740): bad X server connection. DISPLAY=Aborted (core dumped)
When I do echo $DISPLAY inside docker I see nothing. I tried doing
export DISPLAY=unix:0 then I get
root#5e6a10efbea6:/workspaces/leuze_lidar_volume/sdk/quanergy_client-master# ./visualizer --host localhost
ERROR: In /build/vtk6-YpT4yb/vtk6-6.2.0+dfsg1/Rendering/OpenGL/vtkXOpenGLRenderWindow.cxx, line 1466
vtkXOpenGLRenderWindow (0x281dcf0): bad X server connection. DISPLAY=unix:0. Aborting.
Aborted (core dumped)
I also see no /tmp.x11-unix inside the container:
root#5e6a10efbea6:/tmp# ls -la /tmp
total 16
drwxrwxrwt 1 root root 4096 Mar 18 03:47 .
drwxr-xr-x 1 root root 4096 Mar 18 03:45 ..
srwxr-xr-x 1 root root 0 Mar 18 03:42 vscode-git-askpass-c2ca47727522d7940b4cce1d99fcc88d32ccfefc.sock
srwxr-xr-x 1 root root 0 Mar 18 03:47 vscode-git-ipc-f52b0dbfd870db22481ea656170b7615ea1e6497.sock
srwxr-xr-x 1 root root 0 Mar 18 03:45 vscode-ipc-032f3099-16ea-4f5d-8561-586571a4aea9.sock
srwxr-xr-x 1 root root 0 Mar 18 03:32 vscode-ipc-425af2fc-ddb1-4554-b93b-3a5bede4c52d.sock
srwxr-xr-x 1 root root 0 Mar 18 03:47 vscode-ipc-58739ccc-fb7d-4289-808e-21d31c703d1a.sock
srwxr-xr-x 1 root root 0 Mar 18 03:42 vscode-ipc-aa7aed50-92e4-4b2b-b17e-d70c1bba595e.sock
-rw-r--r-- 1 root root 2342 Mar 18 03:46 vscode-remote-containers-6a199ce05d20a43a350860289798f388414d648c.js
srwxr-xr-x 1 root root 0 Mar 18 03:46 vscode-remote-containers-ipc-6a199ce05d20a43a350860289798f388414d648c.sock
srwxr-xr-x 1 root root 0 Mar 18 03:46 vscode-ssh-auth-6a199ce05d20a43a350860289798f388414d648c.sock
drwxr-xr-x 2 root root 4096 Mar 18 03:46 vscode-typescript0
root#5e6a10efbea6:/tmp#
this works:
{
"name": "my_docker_environment",
"dockerFile": "Dockerfile",
"extensions": [
"ms-vscode.cpptools",
"twxs.cmake",
"eamodio.gitlens",
"ms-vscode.cmake-tools"
],
"containerEnv": {
"DISPLAY": "unix:0"
},
"mounts": [
"source=/tmp/.X11-unix,target=/tmp/.X11-unix,type=bind,consistency=cached"
],
"runArgs": ["--privileged"]
}
I don't recall if "runArgs": ["--privileged"] is needed but I guess no
You migth need to do
xhost local:root
on a terminal on the host before launching your app
tested on macOS, the only extra setting in devcontainer.json I used:
"containerEnv": {
"DISPLAY": "docker.for.mac.host.internal:0"
},
on host machine xhost +localhost before running devcontainer

docker error: x509: certificate signed by unknown authority

while running docker commands, I keep getting such error:
$ sudo docker search mattdm/fedora
2014/06/05 22:12:25 Error: Get https://index.docker.io/v1/search?q=mattdm%2Ffedora: x509: certificate signed by unknown authority
I'm using Fedora 20 x86_64 without any http proxy.
I searched with google, but failed to find any clue of this, and have no idea how to troubleshoot this error, could anyone give me some prompt on fixing this?
here is some additional info may help:
$ sudo docker version
Client version: 0.11.1
Client API version: 1.11
Go version (client): go1.2.1
Git commit (client): fb99f99/0.11.1
Server version: 0.11.1
Server API version: 1.11
Git commit (server): fb99f99/0.11.1
Go version (server): go1.2.1
$ curl https://index.docker.io/v1/search?q=mattdm/fedora
{"query": "mattdm/fedora", "num_results": 2, "results": [{"is_trusted": false, "is_official": false, "name": "mattdm/fedora", "star_count": 49, "description": "A basic Fedora image corresponding roughly to a minimal install, minus some things which don't make sense in a container. Use tag `f20` for Fedora 20 or `f19` for Fedora 19."}, {"is_trusted": false, "is_official": false, "name": "mattdm/fedora-small", "star_count": 8, "description": "A small Fedora image on which to build. Contains just enough that you'll be able to run `yum install` in your dockerfiles to create something useful. Use tag `f19` for Fedora 19."}]}
$ ls -l /etc/pki/tls/certs/
total 1500
lrwxrwxrwx. 1 root root 49 Feb 18 03:58 ca-bundle.crt -> /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem
-rw-r--r--. 1 root root 713687 Jan 5 2013 ca-bundle.crt.rpmsave
lrwxrwxrwx. 1 root root 55 Feb 18 03:58 ca-bundle.trust.crt -> /etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt
-rw-r--r--. 1 root root 796502 Jan 5 2013 ca-bundle.trust.crt.rpmsave
-rw-r--r--. 1 root root 1338 Mar 14 12:13 ca-certificates.crt
-rw-------. 1 root root 1025 Sep 25 2012 localhost.crt
-rwxr-xr-x. 1 root root 610 Apr 8 08:36 make-dummy-cert
-rw-r--r--. 1 root root 2242 Apr 8 08:36 Makefile
-rwxr-xr-x. 1 root root 829 Apr 8 08:36 renew-dummy-cert
This was proved to be related to the CDN provider.
check here: https://github.com/dotcloud/docker/issues/6474

Rails 4 gets 403 Forbidden error with Nginx + Passenger deployed with Chef

I'm trying to do an automated build of a complete rails server box and everything works except i'm getting a 403 Forbidden message when accessing the webserver.
Attributes:
#jumpsquares directories
default['www_dir'] = '/var/www'
default['jumpsquares_dir'] = '/var/www/jumpsquares'
#rvm
default['rvm']['default_ruby'] = "ruby-2.1.2"
default['rvm']['user_default_ruby'] = "ruby-2.1.2"
default['rvm']['rubies'] = ["ruby-2.1.2"]
#postgresql
default["postgresql"]["pg_hba_defaults"] = false
default["postgresql"]["pg_hba"] = [
{ "type"=> "local", "db"=> "all", "user"=> "postgres", "addr"=> "", "method"=> "peer" },
{ "type"=> "local", "db"=> "all", "user"=> "all", "addr"=> "", "method"=> "md5" },
{ "type"=> "host", "db"=> "all", "user"=> "all", "addr"=> "127.0.0.1/32", "method"=> "md5" },
{ "type"=> "host", "db"=> "all", "user"=> "all", "addr"=> "::1/128", "method"=> "md5" }
]
#nginx
default['nginx']['version'] = '1.6.0'
default['nginx']['default_root'] = '/var/www/jumpsquares/public'
default['nginx']['rvm_path'] = "/usr/local/rvm/gems/ruby-2.1.2/bin:/usr/local/rvm/gems/ruby-2.1.2#global/bin:/usr/local/rvm/rubies/ruby-2.1.2/bin"
default['nginx']['configure_flags'] = ["--add-module=/usr/local/rvm/gems/ruby-2.1.2/gems/passenger-4.0.42/ext/nginx"]
default['nginx']['source']['modules'] = %w(
nginx::http_ssl_module
nginx::http_gzip_static_module
nginx::passenger
)
default['nginx']['passenger']['version'] = '4.0.42'
default['nginx']['passenger']['root'] = "/usr/local/rvm/gems/ruby-2.1.2/gems/passenger-4.0.42"
default['nginx']['passenger']['ruby'] = "/usr/local/rvm/wrappers/ruby-2.1.2/ruby"
default['nginx']['passenger']['gem_binary'] = "/usr/local/rvm/wrappers/ruby-2.1.2/gem"
Recipe:
include_recipe "apt"
include_recipe "openssl"
include_recipe "rvm::system"
include_recipe "postgresql::server"
include_recipe "postgresql::libpq"
include_recipe "postgresql::client"
pg_user "jumpgres" do
privileges superuser: true, createdb: true, login: true
password "jump123"
end
pg_database "jumpsquares_prod" do
owner "jumpgres"
encoding "UTF-8"
template "template0"
locale "en_US.UTF-8"
end
directory node['www_dir'] do
owner "www-data"
group "www-data"
mode 00755
action :create
end
directory node['jumpsquares_dir'] do
owner "www-data"
group "www-data"
mode 00755
action :create
end
git node['jumpsquares_dir'] do
repository "https://github.com/kacole2/JumpSquares.git"
reference "master"
action :sync
end
rvm_shell "bundle install" do
ruby_string "ruby-2.1.2"
cwd node['jumpsquares_dir']
code %{
source /usr/local/rvm/scripts/rvm
export rvmsudo_secure_path=1
sudo chown -R www-data:www-data "/var/www"
rvmsudo gem install passenger -v 4.0.42 --no-rdoc --no-ri
rvmsudo gem install rake -v 10.3.1 --no-rdoc --no-ri
rvmsudo bundle install
rvmsudo rake RAILS_ENV=appliance-production db:setup
rvmsudo rake RAILS_ENV=appliance-production assets:precompile
}
end
include_recipe "nginx::source"
ENV['PATH']="#{node['nginx']['rvm_path']}:#{ENV['PATH']}"
Here are the resultant nginx files. This is /etc/nginx/nginx.conf:
user www-data;
worker_processes 1;
daemon off;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
gzip on;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_proxied any;
gzip_vary off;
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/rss+xml application/atom+xml text/javascript application/javascript application/json text/mathml;
gzip_min_length 1000;
gzip_disable "MSIE [1-6]\.";
server_names_hash_bucket_size 64;
types_hash_max_size 2048;
types_hash_bucket_size 64;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
/etc/nginx/sites-enabled/000-default
server {
listen 80;
server_name chef-cattle12;
access_log /var/log/nginx/localhost.access.log;
location / {
root /var/www/jumpsquares/public;
index index.html index.htm;
}
}
/etc/nginx/conf.d/passenger.conf
passenger_root /usr/local/rvm/gems/ruby-2.1.2/gems/passenger-4.0.42;
passenger_ruby /usr/local/rvm/wrappers/ruby-2.1.2/ruby;
passenger_max_pool_size 6;
passenger_spawn_method smart-lv2;
passenger_buffer_response on;
passenger_min_instances 1;
passenger_max_instances_per_app 0;
passenger_pool_idle_time 300;
passenger_max_requests 0;
which ruby
administrator#chef-cattle12:~$ which ruby
/usr/local/rvm/rubies/ruby-2.1.2/bin/ruby
administrator#chef-cattle12:~$ passenger-config --root
/usr/local/rvm/gems/ruby-2.1.2/gems/passenger-4.0.42
file permissions are set correctly:
administrator#chef-cattle12:~$ ls -l /var/www
total 4
drwxr-xr-x 14 www-data www-data 4096 May 14 15:29 jumpsquares
administrator#chef-cattle12:~$ ls -l /var/www/jumpsquares/
total 60
drwxr-xr-x 9 www-data www-data 4096 May 14 15:25 app
drwxr-xr-x 2 www-data www-data 4096 May 14 15:25 bin
drwxr-xr-x 5 www-data www-data 4096 May 14 15:25 config
-rw-r--r-x 1 www-data www-data 154 May 14 15:25 config.ru
drwxr-xr-x 3 www-data www-data 4096 May 14 15:25 db
-rw-r--r-x 1 www-data www-data 1313 May 14 15:25 Gemfile
-rw-r--r-x 1 www-data www-data 3583 May 14 15:25 Gemfile.lock
drwxr-xr-x 4 www-data www-data 4096 May 14 15:25 lib
drwxr-xr-x 2 www-data www-data 4096 May 14 15:29 log
drwxr-xr-x 4 www-data www-data 4096 May 14 15:29 public
-rw-r--r-x 1 www-data www-data 254 May 14 15:25 Rakefile
-rw-r--r-x 1 www-data www-data 252 May 14 15:25 README.rdoc
drwxr-xr-x 8 www-data www-data 4096 May 14 15:25 test
drwxr-xr-x 3 www-data www-data 4096 May 14 15:29 tmp
drwxr-xr-x 3 www-data www-data 4096 May 14 15:25 vendor
I have tried just about everything manipulating the nginx.conf file. I've tried removing the index line, moving root out of the location sub portion, and more but nothing seems to work. the logs aren't helping much either. any help is appreciated.
You did not enable Phusion Passenger in your server block and location block. At minimum, you must have 'passenger_enabled on' specified there. Refer to the Phusion Passenger documentation.
i had to add these additional pieces to my recipe for passenger to work correctly
#the passenger configuration is never enabled with the OpsCode nginx cookbook. let's add it
ruby_block "add passenger variable" do
block do
site_file = Chef::Util::FileEdit.new("#{node["nginx"]["dir"]}/sites-enabled/000-default")
site_file.insert_line_after_match(/\slocation\s\/\s{/, " passenger_enabled on;")
site_file.write_file
end
end
#we have to specify the rails environment we want to use since we do not want to use 'production'
ruby_block "add rails environment" do
block do
passenger_file = Chef::Util::FileEdit.new("#{node["nginx"]["dir"]}/conf.d/passenger.conf")
passenger_file.insert_line_if_no_match(/passenger_app_env appliance-production;/, "passenger_app_env appliance-production;")
passenger_file.write_file
end
end

How to use foreman to export to upstart?

I am trying to export my application to another process management format/system (specifically, upstart). In doing so, I have come across a number of roadblocks, mostly due to lacking documentation.
As a non-root user, I ran the following command (as shown here):
-bash> foreman export upstart /etc/init
ERROR: Could not create: /etc/init
I "could not create" the directory due to inadequate permissions, so I used sudo:
-bash> sudo foreman export upstart /etc/init
Password:
ERROR: Could not chown /var/log/app to app
I "could not chown... to app" because there is no user named app.
Where is app coming from?
How should I use forman to export to upstart?
app is default for both the name of the app and the name of the user the application should be run as when the corresponding options (--app and --user) are not used. See the foreman man page for the available options, but note that at the time of this writing the official synopsis did not include [options]:
foreman export [options] <format> [location]
Example:
-bash> sudo foreman export --app foo --user bar upstart /etc/init
Password:
[foreman export] writing: foo.conf
[foreman export] writing: foo-web.conf
[foreman export] writing: foo-web-1.conf
[foreman export] writing: foo-worker.conf
[foreman export] writing: foo-worker-1.conf
Result:
-bash> l /etc/init/
total 80
drwxr-xr-x 12 root wheel 408 20 Oct 09:31 .
drwxr-xr-x 94 root wheel 3196 20 Oct 08:05 ..
-rw-r--r-- 1 root wheel 236 20 Oct 09:31 foo-web-1.conf
-rw-r--r-- 1 root wheel 41 20 Oct 09:31 foo-web.conf
-rw-r--r-- 1 root wheel 220 20 Oct 09:31 foo-worker-1.conf
-rw-r--r-- 1 root wheel 41 20 Oct 09:31 foo-worker.conf
-rw-r--r-- 1 root wheel 315 20 Oct 09:31 foo.conf
-bash> l /var/log/foo/
total 0
drwxr-xr-x 2 bar wheel 68 20 Oct 09:31 .
drwxr-xr-x 45 root wheel 1530 20 Oct 09:31 ..

Resources