VGalaxies opened a new issue, #2228:
URL: https://github.com/apache/incubator-hugegraph/issues/2228

   ### Bug Type (问题类型)
   
   server status (启动/运行异常)
   
   ### Before submit
   
   - [X] 我已经确认现有的 [Issues](https://github.com/apache/hugegraph/issues) 与 
[FAQ](https://hugegraph.apache.org/docs/guides/faq/) 中没有相同 / 重复问题 (I have 
confirmed and searched that there are no similar problems in the historical 
issue and documents)
   
   ### Environment (环境信息)
   
   - Server Version: 1.0.0 (Apache Release Version)
   - OS: macOS 12.3.1 x86_64
   
   ### Expected & Actual behavior (期望与实际表现)
   
   This issue is similar to previous issues:
   
   - https://github.com/apache/incubator-hugegraph/issues/953
   - https://github.com/apache/incubator-hugegraph/issues/978
   
   I following the 
[guide](https://hugegraph.apache.org/docs/clients/gremlin-console/#1-stand-alone-offline-mode)
 to starting Gremlin-Console with the [sample groovy 
script](https://github.com/apache/hugegraph/blob/bcf2a395cf8949c39a127facb404f75cf3842475/hugegraph-dist/src/assembly/static/scripts/example.groovy),
 but it seems like the script was not executed at all, since the print 
statements in the groovy script did not take effect, and the defined variables 
could not be accessed either.
   
   <img width="1026" alt="image" 
src="https://github.com/apache/incubator-hugegraph/assets/79143929/35f20081-a0fe-45a0-a1c7-a7edaab32dfe";>
   
   So I examined the shell script 
[gremlin-console.sh](https://github.com/apache/hugegraph/blob/bcf2a395cf8949c39a127facb404f75cf3842475/hugegraph-dist/src/assembly/static/bin/gremlin-console.sh)
 and found that the command to start the Gremlin-Console is:
   
   ```bash
   exec /Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home/bin/java 
-server -Dtinkerpop.ext=xxx/hugegraph/apache-hugegraph-incubating-1.0.0/ext 
-Dlog4j.configuration=conf/log4j-console.properties -Dgremlin.log4j.level=WARN 
-javaagent:xxx/hugegraph/apache-hugegraph-incubating-1.0.0/lib/jamm-0.3.0.jar 
org.apache.tinkerpop.gremlin.console.Console scripts/example.groovy
   ```
   
   Since the version of tinkerpop declared in the project is 3.5.1, I examined 
the corresponding [source 
code](https://github.com/apache/tinkerpop/blob/3.5.1/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy#L483):
   
   ```groovy
   public static void main(final String[] args) {
        ......
   
        final CliBuilder cli = new CliBuilder()
        cli.stopAtNonOption = false
        cli.name = "gremlin.sh"
   
        ......
   
        cli.i(type: List, longOpt: 'interactive', arity: "1..*", argName: 
"SCRIPT ARG1 ARG2 ...", "Execute the specified script and leave the console 
open on completion")
        cli.e(type: List, longOpt: 'execute', argName: "SCRIPT ARG1 ARG2 ...", 
"Execute the specified script (SCRIPT ARG1 ARG2 ...) and close the console on 
completion")
        cli.C(type: Boolean, longOpt: 'color', "Disable use of ANSI colors")
   
        ......
   ```
   
   I found that `Execute the specified script and leave the console open on 
completion` is match with the running mode here, **but the `-i` option is 
missing in the shell script**.
   
   So I added it, at the same time, I also fixed some obvious issues in the 
groovy script:
   
   <img width="1269" alt="image" 
src="https://github.com/apache/incubator-hugegraph/assets/79143929/3aa5f03a-bb70-4191-9ec1-39f80e725950";>
   
   After that, I run `./bin/gremlin-console.sh scripts/example.groovy` again, 
and it showed:
   
   ```
            \,,,/
            (o o)
   -----oOOo-(3)-oOOo-----
   plugin activated: HugeGraph
   plugin activated: tinkerpop.server
   plugin activated: tinkerpop.utilities
   plugin activated: tinkerpop.tinkergraph
   ERROR StatusLogger Reconfiguration failed: No configuration found for 
'368239c8' at 'null' in 'null'
   main dict load finished, time elapsed 757 ms
   model load finished, time elapsed 49 ms.
   Error in scripts/example.groovy at [39: 
schema.indexLabel("personByCity").onV("person").by("city").secondary().ifNotExist().create()]
 - Failed to update/query TaskStore: java.util.concurrent.ExecutionException: 
org.apache.hugegraph.HugeException: Schema is missing for task(1) 
'INDEX_LABEL:1:personByCity'
   gremlin> schema
   ==>org.apache.hugegraph.schema.SchemaManager@1ad1be5d
   ```
   
   It can be found that the groovy script has been successfully executed, but 
there was a problem when creating the `indexLabel`, why?
   
   By the way, At the beginning, I configured 
`org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin` as 
`example.groovy` in **`gremlin-server.yaml`**. After modifying the above issues 
in the groovy script, I was able to successfully execute the Groovy script when 
**running HugeGraphServer using IDEA**.
   
   <img width="1864" alt="Screen Shot 2023-06-06 at 20 10 18" 
src="https://github.com/apache/incubator-hugegraph/assets/79143929/02cf0436-58b9-48ce-9117-7a9a2dfd34a0";>
   
   
   
    
   
   
   ### Vertex/Edge example (问题点 / 边数据举例)
   
   _No response_
   
   ### Schema [VertexLabel, EdgeLabel, IndexLabel] (元数据结构)
   
   _No response_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to