Has anyone created a snap for cast-web-api? If not, how hard would it be to create one? My understanding is that all you need is to do the following:
Install nodejs and npm
npm install cast-web-api -g
npm install --no-optional forever
Then to start it as a daemon you would need to run forever start `which cast-web-api
I read this documentation and watched a youtube tutorial to try to create my own snap. Alas, it is not working
name: cast-web-api
version: '1.0'
summary: Control your Google Cast devices.
description: >
See what's currently playing pause, play, set the volume and more, all from the SmartThings app. Quickly play your favourite content through presets.
The server runs on your network IP:3000 by default. On error it defaults to 127.0.0.1. Adjustable via:
$ cast-web-api --hostname=192.168.0.11 --port=8080
Run as daemon
$ forever start `which cast-web-api`
grade: devel
confinement: devmode
node-packages:
cast-web-api
forever
parts:
cast-web-api:
plugin: nodejs
source: .
apps:
cast-web-api:
command: cast-web-api
ignacio@ignacio-XPS-8930:~/Documents/cast-web-api$ snapcraft
Issues while validating snapcraft.yaml: Additional properties are not allowed ('node-packages' was unexpected)
I made some progress so i thought i should add a reply instead of modifying my original post (someone may find this useful someday). The following yaml works
name: cast-web-api
version: '1.0'
summary: Control your Google Cast devices.
description: >
See what's currently playing pause, play, set the volume and more, all from the SmartThings app. Quickly play your favourite content through presets.
The server runs on your network IP:3000 by default. On error it defaults to 127.0.0.1. Adjustable via:
$ cast-web-api --hostname=192.168.0.11 --port=8080
Run as daemon
$ cast-web-api-daemon
grade: devel
confinement: devmode
parts:
cast-web-api:
plugin: nodejs
node-packages:
- cast-web-api
- forever
source: .
apps:
cast-web-api:
command: cast-web-api
daemon:
command: forever start `which cast-web-api`
Alas, the command I was expecting to use to run this as a daemon does not work. Moreover, its name is not working
ignacio@ignacio-XPS-8930:~/Documents/cast-web-api$ cast-web-api.daemon
/snap/cast-web-api/x1/command-daemon.wrapper: 1: /snap/cast-web-api/x1/command-daemon.wrapper: which cast-web-api: not found
Any ideas for how to fix that? Any other recommendations for my snap? Ultimately, i want to install this on a raspberry pi running ubuntu core and have the daemon automagically start at boot time.
Thanks @ryanjyoder . I modifyed my yaml to look like this:
name: cast-web-api
version: '1.0'
summary: Control your Google Cast devices.
description: >
See what's currently playing pause, play, set the volume and more, all from the SmartThings app. Quickly play your favourite content through presets.
The server runs on your network IP:3000 by default. On error it defaults to 127.0.0.1. Adjustable via:
$ cast-web-api --hostname=192.168.0.11 --port=8080
grade: devel
confinement: devmode
parts:
cast-web-api:
plugin: nodejs
node-packages:
- cast-web-api
source: .
apps:
cast-web-api:
command: cast-web-api
daemon: simple
I have a couple of questions
After installing the snap do i need to do anything to start the service?
Hmmā¦ Can you paste (or link to) the build logs for the platforms that arenāt building?
BTW, I believe you will need to update your snapcraft.yaml file to included the correct plugs. I believe you will need at least network and network-bind.
I tried installing this snap on my ubuntu core and failed
ignacio82@localhost:~$ snap find cast-web-api
No matching snaps for "cast-web-api"
Is it possible to start the daemon on a different port? By default, the server runs on IP:3000 but it can be adjustable via: cast-web-api - --port=8080 . Is it possible to do that with the snap?
Hard to say why it didnt release just from the screenshot. Do the build logs have any more details about why it didnāt release?
For configuring the port, there are a couple options. You could hard code it in your snapcraft.yaml. command: cast-web-api - --port=8080. If you donāt need to change the port, this would work fine.
Otherwise you would probably want to write a wrapper script to read the configs from a specific location and start the command with the appropriate options. Hereās an example Iāve used:
I was able to get fix my problem but I cannot install the snap on my raspberry pi:
ignacio82@localhost:~$ snap install cast-web-api
error: snap "cast-web-api" is not available on stable but is available to install on the following
channels:
edge snap install --edge cast-web-api
Please be mindful pre-release channels may include features not completely tested or
implemented. Get more information with 'snap info cast-web-api'.
I tried releasing it to the stable channel but it did not work: